You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user_guide.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ This will take care of updating all active tweens; after 1 second (i.e. 1000 mil
50
50
But unless you print the value of `x` to the console, you can't see its value changing. You might want to use the `onUpdate` callback:
51
51
52
52
````javascript
53
-
tween.emit('update', (object) => {
53
+
tween.on('update', (object) => {
54
54
console.log(object.x);
55
55
});
56
56
````
@@ -288,7 +288,7 @@ let trickyObjTween = new TWEEN.Tween({
288
288
propertyB:trickyObj.getPropertyB()
289
289
})
290
290
.to({ propertyA:100, propertyB:200 })
291
-
.emit('update', (object) => {
291
+
.on('update', (object) => {
292
292
object.setA( object.propertyA );
293
293
object.setB( object.propertyB );
294
294
});
@@ -299,29 +299,29 @@ Or imagine you want to play a sound when a tween is started. You can use an `sta
299
299
````javascript
300
300
let tween =newTWEEN.Tween(obj)
301
301
.to({ x:100 })
302
-
.emit('start', () => {
302
+
.once('start', () => {
303
303
sound.play();
304
304
});
305
305
````
306
306
307
307
The scope for each callback is the tweened object--in this case, `obj`.
308
308
309
-
### emit
309
+
### Events
310
310
311
-
In ES6 implementation we try to use `emit` similar to `node.js``emit` events, but easier to use. This way extends flexibility over tweens and reduces size as well. With `emit` method, callback isn't limitation anymore, even you can extend events
311
+
In ES6 implementation we try to use `on`, `once` and `emit` similar to `node.js``emit` events, but easier to use. This way extends flexibility over tweens and reduces size as well. With `event` methods, callback isn't limitation anymore, even you can extend events
312
312
313
313
```javascript
314
-
tween.emit('start', (object) => {
314
+
tween.once('start', (object) => {
315
315
console.log('start called');
316
316
});
317
317
// 'start' calls when tween starts
318
318
319
-
tween.emit('completed_my_tween', (sureArg) => {
319
+
tween.once('completed_my_tween', (sureArg) => {
320
320
console.log('tween is really '+ (sureArg ?'completed':'incompleted'));
0 commit comments