tween.js
Advanced tools
Comparing version 16.3.5 to 16.4.0
{ | ||
"name": "tween.js", | ||
"description": "Super simple, fast and easy to use tweening engine which incorporates optimised Robert Penner's equations.", | ||
"version": "16.3.5", | ||
"version": "16.4.0", | ||
"main": "src/Tween.js", | ||
@@ -32,4 +32,4 @@ "homepage": "https://github.com/tweenjs/tween.js", | ||
"nodeunit": "^0.9.1", | ||
"semantic-release": "^4.3.5" | ||
"semantic-release": "^6.3.2" | ||
} | ||
} | ||
} |
@@ -9,2 +9,3 @@ # tween.js | ||
[![Flattr this][flattr-image]][flattr-url] | ||
[![CDNJS][cdnjs-image]][cdnjs-url] | ||
@@ -36,2 +37,11 @@ ```javascript | ||
Or you can even use minified Tween.js without downloading the file, | ||
for example: | ||
```html | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/tween.js/16.3.5/Tween.min.js"></script> | ||
``` | ||
See Tween.js on [CDNJS](https://github.com/cdnjs/cdnjs): https://cdnjs.com/libraries/tween.js/ | ||
### More advanced users might want to... | ||
@@ -154,1 +164,3 @@ | ||
[flattr-url]: https://flattr.com/thing/45014/tween-js | ||
[cdnjs-image]: https://img.shields.io/cdnjs/v/tween.js.svg | ||
[cdnjs-url]: https://cdnjs.com/libraries/tween.js |
102
src/Tween.js
@@ -72,35 +72,32 @@ /** | ||
// Include a performance.now polyfill | ||
(function () { | ||
// In node.js, use process.hrtime. | ||
if (this.window === undefined && this.process !== undefined) { | ||
TWEEN.now = function () { | ||
var time = process.hrtime(); | ||
// Include a performance.now polyfill. | ||
// In node.js, use process.hrtime. | ||
if (typeof (window) === 'undefined' && typeof (process) !== 'undefined') { | ||
TWEEN.now = function () { | ||
var time = process.hrtime(); | ||
// Convert [seconds, microseconds] to milliseconds. | ||
return time[0] * 1000 + time[1] / 1000; | ||
}; | ||
} | ||
// In a browser, use window.performance.now if it is available. | ||
else if (this.window !== undefined && | ||
window.performance !== undefined && | ||
// Convert [seconds, nanoseconds] to milliseconds. | ||
return time[0] * 1000 + time[1] / 1000000; | ||
}; | ||
} | ||
// In a browser, use window.performance.now if it is available. | ||
else if (typeof (window) !== 'undefined' && | ||
window.performance !== undefined && | ||
window.performance.now !== undefined) { | ||
// This must be bound, because directly assigning this function | ||
// leads to an invocation exception in Chrome. | ||
TWEEN.now = window.performance.now.bind(window.performance); | ||
} | ||
// Use Date.now if it is available. | ||
else if (Date.now !== undefined) { | ||
TWEEN.now = Date.now; | ||
} | ||
// Otherwise, use 'new Date().getTime()'. | ||
else { | ||
TWEEN.now = function () { | ||
return new Date().getTime(); | ||
}; | ||
} | ||
// This must be bound, because directly assigning this function | ||
// leads to an invocation exception in Chrome. | ||
TWEEN.now = window.performance.now.bind(window.performance); | ||
} | ||
// Use Date.now if it is available. | ||
else if (Date.now !== undefined) { | ||
TWEEN.now = Date.now; | ||
} | ||
// Otherwise, use 'new Date().getTime()'. | ||
else { | ||
TWEEN.now = function () { | ||
return new Date().getTime(); | ||
}; | ||
} | ||
})(); | ||
TWEEN.Tween = function (object) { | ||
@@ -114,2 +111,3 @@ | ||
var _repeat = 0; | ||
var _repeatDelayTime; | ||
var _yoyo = false; | ||
@@ -129,9 +127,6 @@ var _isPlaying = false; | ||
// Set all starting values present on the target object | ||
for (var field in object) { | ||
_valuesStart[field] = parseFloat(object[field], 10); | ||
} | ||
this.to = function (properties, duration) { | ||
_valuesEnd = properties; | ||
if (duration !== undefined) { | ||
@@ -141,4 +136,2 @@ _duration = duration; | ||
_valuesEnd = properties; | ||
return this; | ||
@@ -175,6 +168,7 @@ | ||
// we should not set that property in the object | ||
if (_valuesStart[property] === undefined) { | ||
if (_object[property] === undefined) { | ||
continue; | ||
} | ||
// Save the starting value. | ||
_valuesStart[property] = _object[property]; | ||
@@ -204,3 +198,3 @@ | ||
if (_onStopCallback !== null) { | ||
_onStopCallback.call(_object); | ||
_onStopCallback.call(_object, _object); | ||
} | ||
@@ -213,2 +207,9 @@ | ||
this.end = function () { | ||
this.update(_startTime + _duration); | ||
return this; | ||
}; | ||
this.stopChainedTweens = function () { | ||
@@ -236,2 +237,9 @@ | ||
this.repeatDelay = function (amount) { | ||
_repeatDelayTime = amount; | ||
return this; | ||
}; | ||
this.yoyo = function (yoyo) { | ||
@@ -307,7 +315,6 @@ | ||
if (_onStartCallback !== null) { | ||
_onStartCallback.call(_object); | ||
_onStartCallback.call(_object, _object); | ||
} | ||
_onStartCallbackFired = true; | ||
} | ||
@@ -340,5 +347,5 @@ | ||
if (end.charAt(0) === '+' || end.charAt(0) === '-') { | ||
end = start + parseFloat(end, 10); | ||
end = start + parseFloat(end); | ||
} else { | ||
end = parseFloat(end, 10); | ||
end = parseFloat(end); | ||
} | ||
@@ -372,3 +379,3 @@ } | ||
if (typeof (_valuesEnd[property]) === 'string') { | ||
_valuesStartRepeat[property] = _valuesStartRepeat[property] + parseFloat(_valuesEnd[property], 10); | ||
_valuesStartRepeat[property] = _valuesStartRepeat[property] + parseFloat(_valuesEnd[property]); | ||
} | ||
@@ -391,3 +398,7 @@ | ||
_startTime = time + _delayTime; | ||
if (_repeatDelayTime !== undefined) { | ||
_startTime = time + _repeatDelayTime; | ||
} else { | ||
_startTime = time + _delayTime; | ||
} | ||
@@ -399,3 +410,4 @@ return true; | ||
if (_onCompleteCallback !== null) { | ||
_onCompleteCallback.call(_object); | ||
_onCompleteCallback.call(_object, _object); | ||
} | ||
@@ -402,0 +414,0 @@ |
Sorry, the diff of this file is not supported yet
24065
546
164