Skip to content

Commit 910813e

Browse files
committed
fix: make the examples work locally (fixes gajus#75)
1 parent dfd1f6b commit 910813e

File tree

10 files changed

+36
-8
lines changed

10 files changed

+36
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Give it a [swing](http://gajus.com/sandbox/swing/examples/card-stack/)! and plea
3535
* [Programmatically control](http://gajus.com/sandbox/swing/examples/card-state/) the state of the card.
3636
* [Indicate the state of the drop](http://gajus.com/sandbox/swing/examples/throw-confidence/) using `throwConfidence` and `direction` [event object](#event-object) properties.
3737

38-
The code for all of the examples is in the [./examples/](https://github.com/gajus/swing/tree/master/examples/) folder.
38+
The code for all of the examples is in the [./examples/](./examples/) folder.
3939

4040
[Raise an issue](https://github.com/gajus/swing/issues) if you are missing an example.
4141

examples/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
To run locally:
2+
3+
```bash
4+
git clone [email protected]:gajus/swing.git
5+
cd ./swing/examples
6+
npm install
7+
npm start
8+
```
9+
10+
This will start server on port 8080:
11+
12+
```bash
13+
open http://localhost:8080/
14+
```

examples/card-stack/card-stack.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
document.addEventListener('DOMContentLoaded', function () {
22
var stack;
33

4-
stack = gajus.Swing.Stack();
4+
stack = window.swing.Stack();
55

66
[].forEach.call(document.querySelectorAll('.stack li'), function (targetElement) {
77
stack.createCard(targetElement);

examples/card-stack/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
99

10-
<script src="./../../dist/browser/swing.js"></script>
10+
<script src="http://localhost:8080/bundle.js"></script>
1111
<script src="./card-stack.js"></script>
1212
</head>
1313
<body>

examples/card-state/card-state.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
document.addEventListener('DOMContentLoaded', function () {
2-
var stack = gajus.Swing.Stack(),
2+
var stack = window.swing.Stack(),
33
cardElement = document.querySelector('.stack li');
44

55
window.card = stack.createCard(cardElement);
@@ -11,4 +11,4 @@ document.addEventListener('DOMContentLoaded', function () {
1111
stack.on('throwin', function (e) {
1212
console.log(e.target.innerText || e.target.textContent, 'has been thrown into the stack from the', e.throwDirection, 'direction.');
1313
});
14-
});
14+
});

examples/card-state/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
99

10-
<script src="../../dist/browser/swing.js"></script>
10+
<script src="http://localhost:8080/bundle.js"></script>
1111
<script src="./card-state.js"></script>
1212
</head>
1313
<body>

examples/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
window.swing = require('swing');

examples/package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"dependencies": {
3+
"swing": "^4.0.1"
4+
},
5+
"devDependencies": {
6+
"webpack": "^1.14.0",
7+
"webpack-dev-server": "^1.16.2"
8+
},
9+
"private": true,
10+
"scripts": {
11+
"start": "webpack-dev-server --entry ./index.js"
12+
}
13+
}

examples/throw-confidence/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
1010

11-
<script src="./../../dist/browser/swing.js"></script>
11+
<script src="http://localhost:8080/bundle.js"></script>
1212
<script src="./throw-confidence.js"></script>
1313
</head>
1414
<body>

examples/throw-confidence/throw-confidence.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ document.addEventListener('DOMContentLoaded', function () {
55
directionBind,
66
throwOutConfidenceElements;
77

8-
stack = gajus.Swing.Stack();
8+
stack = window.swing.Stack();
99
cardElement = document.querySelector('.stack li');
1010
throwOutConfidenceBind = document.querySelector('#throw-out-confidence-bind');
1111
directionBind = document.querySelector('#direction-bind');

0 commit comments

Comments
 (0)