@tweenjs/tween.js 17.2.0 → 17.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tweenjs/tween.js",
3
3
  "description": "Super simple, fast and easy to use tweening engine which incorporates optimised Robert Penner's equations.",
4
- "version": "17.2.0",
4
+ "version": "17.4.0",
5
5
  "main": "src/Tween.js",
6
6
  "homepage": "https://github.com/tweenjs/tween.js",
7
7
  "repository": {
@@ -22,13 +22,13 @@
22
22
  "test-unit": "nodeunit test/unit/nodeunitheadless.js",
23
23
  "test-correctness": "jshint --config test/jshintrc src/Tween.js",
24
24
  "test-style": "jscs --config test/jscs.json src/Tween.js",
25
- "semantic-release": "semantic-release pre && npm publish && semantic-release post"
25
+ "semantic-release": "semantic-release"
26
26
  },
27
27
  "author": "tween.js contributors (https://github.com/tweenjs/tween.js/graphs/contributors)",
28
28
  "devDependencies": {
29
29
  "jscs": "^2.11.0",
30
30
  "jshint": "^2.9.4",
31
31
  "nodeunit": "^0.9.5",
32
- "semantic-release": "^6.3.2"
32
+ "semantic-release": "^15.13.12"
33
33
  }
34
34
  }
package/src/Tween.js CHANGED
@@ -91,7 +91,7 @@ TWEEN.nextId = function () {
91
91
 
92
92
  // Include a performance.now polyfill.
93
93
  // In node.js, use process.hrtime.
94
- if (typeof (window) === 'undefined' && typeof (process) !== 'undefined') {
94
+ if (typeof (self) === 'undefined' && typeof (process) !== 'undefined' && process.hrtime) {
95
95
  TWEEN.now = function () {
96
96
  var time = process.hrtime();
97
97
 
@@ -99,13 +99,13 @@ if (typeof (window) === 'undefined' && typeof (process) !== 'undefined') {
99
99
  return time[0] * 1000 + time[1] / 1000000;
100
100
  };
101
101
  }
102
- // In a browser, use window.performance.now if it is available.
103
- else if (typeof (window) !== 'undefined' &&
104
- window.performance !== undefined &&
105
- window.performance.now !== undefined) {
102
+ // In a browser, use self.performance.now if it is available.
103
+ else if (typeof (self) !== 'undefined' &&
104
+ self.performance !== undefined &&
105
+ self.performance.now !== undefined) {
106
106
  // This must be bound, because directly assigning this function
107
107
  // leads to an invocation exception in Chrome.
108
- TWEEN.now = window.performance.now.bind(window.performance);
108
+ TWEEN.now = self.performance.now.bind(self.performance);
109
109
  }
110
110
  // Use Date.now if it is available.
111
111
  else if (Date.now !== undefined) {
@@ -138,6 +138,7 @@ TWEEN.Tween = function (object, group) {
138
138
  this._onStartCallback = null;
139
139
  this._onStartCallbackFired = false;
140
140
  this._onUpdateCallback = null;
141
+ this._onRepeatCallback = null;
141
142
  this._onCompleteCallback = null;
142
143
  this._onStopCallback = null;
143
144
  this._group = group || TWEEN;
@@ -146,17 +147,17 @@ TWEEN.Tween = function (object, group) {
146
147
  };
147
148
 
148
149
  TWEEN.Tween.prototype = {
149
- getId: function getId() {
150
+ getId: function () {
150
151
  return this._id;
151
152
  },
152
153
 
153
- isPlaying: function isPlaying() {
154
+ isPlaying: function () {
154
155
  return this._isPlaying;
155
156
  },
156
157
 
157
- to: function to(properties, duration) {
158
+ to: function (properties, duration) {
158
159
 
159
- this._valuesEnd = properties;
160
+ this._valuesEnd = Object.create(properties);
160
161
 
161
162
  if (duration !== undefined) {
162
163
  this._duration = duration;
@@ -166,7 +167,12 @@ TWEEN.Tween.prototype = {
166
167
 
167
168
  },
168
169
 
169
- start: function start(time) {
170
+ duration: function duration(d) {
171
+ this._duration = d;
172
+ return this;
173
+ },
174
+
175
+ start: function (time) {
170
176
 
171
177
  this._group.add(this);
172
178
 
@@ -212,7 +218,7 @@ TWEEN.Tween.prototype = {
212
218
 
213
219
  },
214
220
 
215
- stop: function stop() {
221
+ stop: function () {
216
222
 
217
223
  if (!this._isPlaying) {
218
224
  return this;
@@ -230,14 +236,14 @@ TWEEN.Tween.prototype = {
230
236
 
231
237
  },
232
238
 
233
- end: function end() {
239
+ end: function () {
234
240
 
235
- this.update(this._startTime + this._duration);
241
+ this.update(Infinity);
236
242
  return this;
237
243
 
238
244
  },
239
245
 
240
- stopChainedTweens: function stopChainedTweens() {
246
+ stopChainedTweens: function () {
241
247
 
242
248
  for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
243
249
  this._chainedTweens[i].stop();
@@ -245,89 +251,96 @@ TWEEN.Tween.prototype = {
245
251
 
246
252
  },
247
253
 
248
- group: function group(group) {
254
+ group: function (group) {
249
255
  this._group = group;
250
256
  return this;
251
257
  },
252
258
 
253
- delay: function delay(amount) {
259
+ delay: function (amount) {
254
260
 
255
261
  this._delayTime = amount;
256
262
  return this;
257
263
 
258
264
  },
259
265
 
260
- repeat: function repeat(times) {
266
+ repeat: function (times) {
261
267
 
262
268
  this._repeat = times;
263
269
  return this;
264
270
 
265
271
  },
266
272
 
267
- repeatDelay: function repeatDelay(amount) {
273
+ repeatDelay: function (amount) {
268
274
 
269
275
  this._repeatDelayTime = amount;
270
276
  return this;
271
277
 
272
278
  },
273
279
 
274
- yoyo: function yoyo(yy) {
280
+ yoyo: function (yoyo) {
275
281
 
276
- this._yoyo = yy;
282
+ this._yoyo = yoyo;
277
283
  return this;
278
284
 
279
285
  },
280
286
 
281
- easing: function easing(eas) {
287
+ easing: function (easingFunction) {
282
288
 
283
- this._easingFunction = eas;
289
+ this._easingFunction = easingFunction;
284
290
  return this;
285
291
 
286
292
  },
287
293
 
288
- interpolation: function interpolation(inter) {
294
+ interpolation: function (interpolationFunction) {
289
295
 
290
- this._interpolationFunction = inter;
296
+ this._interpolationFunction = interpolationFunction;
291
297
  return this;
292
298
 
293
299
  },
294
300
 
295
- chain: function chain() {
301
+ chain: function () {
296
302
 
297
303
  this._chainedTweens = arguments;
298
304
  return this;
299
305
 
300
306
  },
301
307
 
302
- onStart: function onStart(callback) {
308
+ onStart: function (callback) {
303
309
 
304
310
  this._onStartCallback = callback;
305
311
  return this;
306
312
 
307
313
  },
308
314
 
309
- onUpdate: function onUpdate(callback) {
315
+ onUpdate: function (callback) {
310
316
 
311
317
  this._onUpdateCallback = callback;
312
318
  return this;
313
319
 
314
320
  },
315
321
 
316
- onComplete: function onComplete(callback) {
322
+ onRepeat: function onRepeat(callback) {
323
+
324
+ this._onRepeatCallback = callback;
325
+ return this;
326
+
327
+ },
328
+
329
+ onComplete: function (callback) {
317
330
 
318
331
  this._onCompleteCallback = callback;
319
332
  return this;
320
333
 
321
334
  },
322
335
 
323
- onStop: function onStop(callback) {
336
+ onStop: function (callback) {
324
337
 
325
338
  this._onStopCallback = callback;
326
339
  return this;
327
340
 
328
341
  },
329
342
 
330
- update: function update(time) {
343
+ update: function (time) {
331
344
 
332
345
  var property;
333
346
  var elapsed;
@@ -387,7 +400,7 @@ TWEEN.Tween.prototype = {
387
400
  }
388
401
 
389
402
  if (this._onUpdateCallback !== null) {
390
- this._onUpdateCallback(this._object);
403
+ this._onUpdateCallback(this._object, elapsed);
391
404
  }
392
405
 
393
406
  if (elapsed === 1) {
@@ -426,6 +439,10 @@ TWEEN.Tween.prototype = {
426
439
  this._startTime = time + this._delayTime;
427
440
  }
428
441
 
442
+ if (this._onRepeatCallback !== null) {
443
+ this._onRepeatCallback(this._object);
444
+ }
445
+
429
446
  return true;
430
447
 
431
448
  } else {