es6-tween
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -582,5 +582,7 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -603,461 +605,486 @@ | ||
var Tween = function () { | ||
function Tween() { | ||
var object = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
_createClass(Tween, null, [{ | ||
key: 'createEmptyConst', | ||
value: function createEmptyConst(oldObject) { | ||
return typeof oldObject === "number" ? 0 : Array.isArray(oldObject) ? [] : (typeof oldObject === 'undefined' ? 'undefined' : _typeof(oldObject)) === "object" ? {} : ''; | ||
} | ||
}]); | ||
_classCallCheck(this, Tween); | ||
function Tween() { | ||
var object = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
this.object = object; | ||
this._valuesStart = Object.assign({}, object); | ||
this._valuesStartRepeat = Object.assign({}, object); | ||
this._valuesEnd = {}; | ||
this._chainedTweens = []; | ||
_classCallCheck(this, Tween); | ||
this._duration = 1000; | ||
this._easingFunction = _Easing2.default.Linear.None; | ||
this._interpolationFunction = _Interpolation2.default.None; | ||
this.object = object; | ||
this._valuesStart = Object.assign(Tween.createEmptyConst(object), object); | ||
this._valuesStartRepeat = Object.assign(Tween.createEmptyConst(object), object); | ||
this._valuesEnd = Tween.createEmptyConst(object); | ||
this._chainedTweens = []; | ||
this._startTime = 0; | ||
this._delayTime = 0; | ||
this._repeat = 0; | ||
this._r = 0; | ||
this._repeatDelayTime = 0; | ||
this._reverseDelayTime = 0; | ||
this._isPlaying = false; | ||
this._yoyo = false; | ||
this._reversed = false; | ||
this._duration = 1000; | ||
this._easingFunction = _Easing2.default.Linear.None; | ||
this._interpolationFunction = _Interpolation2.default.None; | ||
this._onStartCallbackFired = false; | ||
this._events = {}; | ||
this._pausedTime = 0; | ||
this._startTime = 0; | ||
this._delayTime = 0; | ||
this._repeat = 0; | ||
this._r = 0; | ||
this._repeatDelayTime = 0; | ||
this._reverseDelayTime = 0; | ||
this._isPlaying = false; | ||
this._yoyo = false; | ||
this._reversed = false; | ||
return this; | ||
this._onStartCallbackFired = false; | ||
this._events = {}; | ||
this._pausedTime = 0; | ||
return this; | ||
} | ||
_createClass(Tween, [{ | ||
key: 'isPlaying', | ||
value: function isPlaying() { | ||
return this._isPlaying; | ||
} | ||
}, { | ||
key: 'isStarted', | ||
value: function isStarted() { | ||
return this._onStartCallbackFired; | ||
} | ||
}, { | ||
key: 'reverse', | ||
value: function reverse() { | ||
var _valuesStartRepeat = this._valuesStartRepeat, | ||
_yoyo = this._yoyo, | ||
_valuesEnd = this._valuesEnd, | ||
_valuesStart = this._valuesStart; | ||
_createClass(Tween, [{ | ||
key: 'isPlaying', | ||
value: function isPlaying() { | ||
return this._isPlaying; | ||
} | ||
}, { | ||
key: 'isStarted', | ||
value: function isStarted() { | ||
return this._onStartCallbackFired; | ||
} | ||
}, { | ||
key: 'reverse', | ||
value: function reverse() { | ||
var _valuesStartRepeat = this._valuesStartRepeat, | ||
_yoyo = this._yoyo, | ||
_valuesEnd = this._valuesEnd, | ||
_valuesStart = this._valuesStart; | ||
// Reassign starting values, restart by making startTime = now | ||
// Reassign starting values, restart by making startTime = now | ||
for (var property in _valuesStartRepeat) { | ||
for (var property in _valuesStartRepeat) { | ||
if (typeof _valuesEnd[property] === 'string') { | ||
_valuesStartRepeat[property] = _valuesStartRepeat[property] + parseFloat(_valuesEnd[property]); | ||
} | ||
if (typeof _valuesEnd[property] === 'string') { | ||
_valuesStartRepeat[property] = _valuesStartRepeat[property] + parseFloat(_valuesEnd[property]); | ||
} | ||
if (_yoyo) { | ||
var tmp = _valuesStartRepeat[property]; | ||
if (_yoyo) { | ||
var tmp = _valuesStartRepeat[property]; | ||
_valuesStartRepeat[property] = _valuesEnd[property]; | ||
_valuesEnd[property] = tmp; | ||
} | ||
_valuesStartRepeat[property] = _valuesEnd[property]; | ||
_valuesEnd[property] = tmp; | ||
} | ||
_valuesStart[property] = _valuesStartRepeat[property]; | ||
} | ||
_valuesStart[property] = _valuesStartRepeat[property]; | ||
} | ||
this._reversed = !this._reversed; | ||
this._reversed = !this._reversed; | ||
return this; | ||
} | ||
}, { | ||
key: 'off', | ||
value: function off(name, fn) { | ||
if (this._events[name] === undefined) { | ||
return this; | ||
} | ||
if (name !== undefined && fn !== undefined) { | ||
this._events[name].filter(function (event) { | ||
if (event === fn) { | ||
return false; | ||
} | ||
return true; | ||
}); | ||
} else if (name !== undefined && fn === undefined) { | ||
this._events[name] = []; | ||
} | ||
return this; | ||
} | ||
}, { | ||
key: 'on', | ||
value: function on(name, fn) { | ||
if (this._events[name] === undefined) { | ||
this._events[name] = []; | ||
} | ||
this._events[name].push(fn); | ||
return this; | ||
} | ||
}, { | ||
key: 'once', | ||
value: function once(name, fn) { | ||
var _this = this; | ||
return this; | ||
if (this._events[name] === undefined) { | ||
this._events[name] = []; | ||
} | ||
return this.on(name, function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
}, { | ||
key: 'off', | ||
value: function off(name, fn) { | ||
if (this._events[name] === undefined) { | ||
return this; | ||
} | ||
if (name !== undefined && fn !== undefined) { | ||
this._events[name].filter(function (event) { | ||
if (event === fn) { | ||
return false; | ||
} | ||
return true; | ||
}); | ||
} else if (name !== undefined && fn === undefined) { | ||
this._events[name] = []; | ||
} | ||
return this; | ||
} | ||
}, { | ||
key: 'on', | ||
value: function on(name, fn) { | ||
if (this._events[name] === undefined) { | ||
this._events[name] = []; | ||
} | ||
this._events[name].push(fn); | ||
return this; | ||
} | ||
}, { | ||
key: 'once', | ||
value: function once(name, fn) { | ||
var _this = this; | ||
if (this._events[name] === undefined) { | ||
this._events[name] = []; | ||
} | ||
return this.on(name, function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
fn.call.apply(fn, [_this].concat(args)); | ||
_this.off(name); | ||
}); | ||
} | ||
}, { | ||
key: 'emit', | ||
value: function emit(name) { | ||
var _this2 = this; | ||
fn.call.apply(fn, [_this].concat(args)); | ||
_this.off(name); | ||
}); | ||
} | ||
}, { | ||
key: 'emit', | ||
value: function emit(name) { | ||
var _this2 = this; | ||
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
args[_key2 - 1] = arguments[_key2]; | ||
} | ||
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
args[_key2 - 1] = arguments[_key2]; | ||
} | ||
if (this._events[name] === undefined) { | ||
return this; | ||
} | ||
this._events[name].map(function (event) { | ||
event.call.apply(event, [_this2].concat(args)); | ||
}); | ||
return this; | ||
} | ||
}, { | ||
key: 'pause', | ||
value: function pause() { | ||
if (this._events[name] === undefined) { | ||
return this; | ||
} | ||
this._events[name].map(function (event) { | ||
event.call.apply(event, [_this2].concat(args)); | ||
}); | ||
return this; | ||
} | ||
}, { | ||
key: 'pause', | ||
value: function pause() { | ||
if (!this._isPlaying) { | ||
return this; | ||
} | ||
if (!this._isPlaying) { | ||
return this; | ||
} | ||
this._isPlaying = false; | ||
this._isPlaying = false; | ||
TWEEN.remove(this); | ||
this._pausedTime = TWEEN.now(); | ||
TWEEN.remove(this); | ||
this._pausedTime = TWEEN.now(); | ||
return this.emit('pause', this.object); | ||
} | ||
}, { | ||
key: 'play', | ||
value: function play() { | ||
return this.emit('pause', this.object); | ||
} | ||
}, { | ||
key: 'play', | ||
value: function play() { | ||
if (this._isPlaying) { | ||
return this; | ||
} | ||
if (this._isPlaying) { | ||
return this; | ||
} | ||
this._isPlaying = true; | ||
this._isPlaying = true; | ||
this._startTime += TWEEN.now() - this._pausedTime; | ||
TWEEN.add(this); | ||
this._pausedTime = TWEEN.now(); | ||
this._startTime += TWEEN.now() - this._pausedTime; | ||
TWEEN.add(this); | ||
this._pausedTime = TWEEN.now(); | ||
return this.emit('play', this.object); | ||
} | ||
}, { | ||
key: 'restart', | ||
value: function restart(noDelay) { | ||
return this.emit('play', this.object); | ||
} | ||
}, { | ||
key: 'restart', | ||
value: function restart(noDelay) { | ||
this._startTime = TWEEN.now() + (noDelay ? 0 : this._delayTime); | ||
this._startTime = TWEEN.now() + (noDelay ? 0 : this._delayTime); | ||
if (!this._isPlaying) { | ||
TWEEN.add(this); | ||
} | ||
if (!this._isPlaying) { | ||
TWEEN.add(this); | ||
} | ||
return this.emit('restart', this._object); | ||
} | ||
}, { | ||
key: 'seek', | ||
value: function seek(time, keepPlaying) { | ||
return this.emit('restart', this._object); | ||
} | ||
}, { | ||
key: 'seek', | ||
value: function seek(time, keepPlaying) { | ||
this._startTime = TWEEN.now() + Math.max(0, Math.min(time, this._duration)); | ||
this._startTime = TWEEN.now() + Math.max(0, Math.min(time, this._duration)); | ||
this.emit('seek', time, this._object); | ||
this.emit('seek', time, this._object); | ||
return keepPlaying ? this : this.pause(); | ||
} | ||
}, { | ||
key: 'duration', | ||
value: function duration(amount) { | ||
return keepPlaying ? this : this.pause(); | ||
} | ||
}, { | ||
key: 'duration', | ||
value: function duration(amount) { | ||
this._duration = amount; | ||
this._duration = amount; | ||
return this; | ||
} | ||
}, { | ||
key: 'to', | ||
value: function to() { | ||
var properties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000; | ||
return this; | ||
} | ||
}, { | ||
key: 'to', | ||
value: function to() { | ||
var properties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000; | ||
if (typeof properties === "number") { | ||
var _vE = { Number: properties }; | ||
this._valuesEnd = _vE; | ||
} else { | ||
this._valuesEnd = properties; | ||
} | ||
this._valuesEnd = properties; | ||
this._duration = duration; | ||
return this; | ||
if (typeof duration === "number") { | ||
this._duration = duration; | ||
} else if ((typeof duration === 'undefined' ? 'undefined' : _typeof(duration)) === "object") { | ||
for (var prop in duration) { | ||
this[prop](duration[prop]); | ||
} | ||
}, { | ||
key: 'start', | ||
value: function start(time) { | ||
var _startTime = this._startTime, | ||
_delayTime = this._delayTime; | ||
} | ||
return this; | ||
} | ||
}, { | ||
key: 'start', | ||
value: function start(time) { | ||
var _startTime = this._startTime, | ||
_delayTime = this._delayTime; | ||
_startTime = time !== undefined ? time : TWEEN.now(); | ||
_startTime += _delayTime; | ||
this._startTime = _startTime; | ||
_startTime = time !== undefined ? time : TWEEN.now(); | ||
_startTime += _delayTime; | ||
TWEEN.add(this); | ||
this._startTime = _startTime; | ||
this._isPlaying = true; | ||
TWEEN.add(this); | ||
return this; | ||
} | ||
}, { | ||
key: 'stop', | ||
value: function stop() { | ||
var _isPlaying = this._isPlaying, | ||
_onStopCallback = this._onStopCallback, | ||
object = this.object; | ||
this._isPlaying = true; | ||
return this; | ||
} | ||
}, { | ||
key: 'stop', | ||
value: function stop() { | ||
var _isPlaying = this._isPlaying, | ||
_onStopCallback = this._onStopCallback, | ||
object = this.object; | ||
if (!_isPlaying) { | ||
return this; | ||
} | ||
TWEEN.remove(this); | ||
this._isPlaying = false; | ||
if (!_isPlaying) { | ||
return this; | ||
} | ||
this.stopChainedTweens(); | ||
return this.emit('stop', object); | ||
} | ||
}, { | ||
key: 'end', | ||
value: function end() { | ||
var _startTime = this._startTime, | ||
_duration = this._duration; | ||
TWEEN.remove(this); | ||
this._isPlaying = false; | ||
this.stopChainedTweens(); | ||
return this.emit('stop', object); | ||
} | ||
}, { | ||
key: 'end', | ||
value: function end() { | ||
var _startTime = this._startTime, | ||
_duration = this._duration; | ||
return this.update(_startTime + _duration); | ||
} | ||
}, { | ||
key: 'stopChainedTweens', | ||
value: function stopChainedTweens() { | ||
var _chainedTweens = this._chainedTweens; | ||
return this.update(_startTime + _duration); | ||
} | ||
}, { | ||
key: 'stopChainedTweens', | ||
value: function stopChainedTweens() { | ||
var _chainedTweens = this._chainedTweens; | ||
_chainedTweens.map(function (item) { | ||
return item.stop(); | ||
}); | ||
return this; | ||
} | ||
}, { | ||
key: 'delay', | ||
value: function delay(amount) { | ||
_chainedTweens.map(function (item) { | ||
return item.stop(); | ||
}); | ||
this._delayTime = amount; | ||
return this; | ||
} | ||
}, { | ||
key: 'delay', | ||
value: function delay(amount) { | ||
return this; | ||
} | ||
}, { | ||
key: 'repeat', | ||
value: function repeat(times) { | ||
this._delayTime = amount; | ||
this._repeat = times; | ||
this._r = times; | ||
return this; | ||
} | ||
}, { | ||
key: 'repeat', | ||
value: function repeat(times) { | ||
return this; | ||
} | ||
}, { | ||
key: 'repeatDelay', | ||
value: function repeatDelay(amount) { | ||
this._repeat = times; | ||
this._r = times; | ||
this._repeatDelayTime = amount; | ||
return this; | ||
} | ||
}, { | ||
key: 'repeatDelay', | ||
value: function repeatDelay(amount) { | ||
return this; | ||
} | ||
}, { | ||
key: 'reverseDelay', | ||
value: function reverseDelay(amount) { | ||
this._repeatDelayTime = amount; | ||
this._reverseDelayTime = amount; | ||
return this; | ||
} | ||
}, { | ||
key: 'reverseDelay', | ||
value: function reverseDelay(amount) { | ||
return this; | ||
} | ||
}, { | ||
key: 'yoyo', | ||
value: function yoyo(state) { | ||
this._reverseDelayTime = amount; | ||
this._yoyo = state; | ||
return this; | ||
} | ||
}, { | ||
key: 'yoyo', | ||
value: function yoyo(state) { | ||
return this; | ||
} | ||
}, { | ||
key: 'easing', | ||
value: function easing(fn) { | ||
this._yoyo = state; | ||
this._easingFunction = fn; | ||
return this; | ||
} | ||
}, { | ||
key: 'easing', | ||
value: function easing(fn) { | ||
return this; | ||
} | ||
}, { | ||
key: 'interpolation', | ||
value: function interpolation(fn) { | ||
this._easingFunction = fn; | ||
this._interpolationFunction = fn; | ||
return this; | ||
} | ||
}, { | ||
key: 'interpolation', | ||
value: function interpolation(fn) { | ||
return this; | ||
} | ||
}, { | ||
key: 'chain', | ||
value: function chain() { | ||
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
args[_key3] = arguments[_key3]; | ||
} | ||
this._interpolationFunction = fn; | ||
this._chainedTweens = args; | ||
return this; | ||
} | ||
}, { | ||
key: 'chain', | ||
value: function chain() { | ||
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
args[_key3] = arguments[_key3]; | ||
} | ||
return this; | ||
} | ||
}, { | ||
key: 'update', | ||
value: function update(time) { | ||
var _onStartCallbackFired = this._onStartCallbackFired, | ||
_chainedTweens = this._chainedTweens, | ||
_easingFunction = this._easingFunction, | ||
_interpolationFunction = this._interpolationFunction, | ||
_repeat = this._repeat, | ||
_repeatDelayTime = this._repeatDelayTime, | ||
_reverseDelayTime = this._reverseDelayTime, | ||
_delayTime = this._delayTime, | ||
_yoyo = this._yoyo, | ||
_reversed = this._reversed, | ||
_startTime = this._startTime, | ||
_duration = this._duration, | ||
_valuesStart = this._valuesStart, | ||
_valuesStartRepeat = this._valuesStartRepeat, | ||
_valuesEnd = this._valuesEnd, | ||
object = this.object; | ||
this._chainedTweens = args; | ||
return this; | ||
} | ||
}, { | ||
key: 'get', | ||
value: function get(time) { | ||
this.update(time); | ||
return this._object; | ||
} | ||
}, { | ||
key: 'update', | ||
value: function update(time) { | ||
var _onStartCallbackFired = this._onStartCallbackFired, | ||
_chainedTweens = this._chainedTweens, | ||
_easingFunction = this._easingFunction, | ||
_interpolationFunction = this._interpolationFunction, | ||
_repeat = this._repeat, | ||
_repeatDelayTime = this._repeatDelayTime, | ||
_reverseDelayTime = this._reverseDelayTime, | ||
_delayTime = this._delayTime, | ||
_yoyo = this._yoyo, | ||
_reversed = this._reversed, | ||
_startTime = this._startTime, | ||
_duration = this._duration, | ||
_valuesStart = this._valuesStart, | ||
_valuesStartRepeat = this._valuesStartRepeat, | ||
_valuesEnd = this._valuesEnd, | ||
object = this.object; | ||
var property = void 0; | ||
var elapsed = void 0; | ||
var value = void 0; | ||
if (time < _startTime) { | ||
return true; | ||
} | ||
var property = void 0; | ||
var elapsed = void 0; | ||
var value = void 0; | ||
if (_onStartCallbackFired === false) { | ||
if (time < _startTime) { | ||
return true; | ||
} | ||
this.emit('start', object); | ||
if (_onStartCallbackFired === false) { | ||
this._onStartCallbackFired = true; | ||
} | ||
this.emit('start', object); | ||
elapsed = (time - _startTime) / _duration; | ||
elapsed = elapsed > 1 ? 1 : elapsed; | ||
this._onStartCallbackFired = true; | ||
} | ||
value = _easingFunction(elapsed); | ||
elapsed = (time - _startTime) / _duration; | ||
elapsed = elapsed > 1 ? 1 : elapsed; | ||
for (property in _valuesEnd) { | ||
value = _easingFunction(elapsed); | ||
var start = _valuesStart[property]; | ||
var end = _valuesEnd[property]; | ||
for (property in _valuesEnd) { | ||
if (end instanceof Array) { | ||
var start = _valuesStart[property]; | ||
var end = _valuesEnd[property]; | ||
object[property] = _interpolationFunction(end, value); | ||
} else { | ||
if (end instanceof Array) { | ||
// Parses relative end values with start as base (e.g.: +10, -3) | ||
if (typeof end === 'string') { | ||
object[property] = _interpolationFunction(end, value); | ||
} else { | ||
if (end.charAt(0) === '+' || end.charAt(0) === '-') { | ||
end = start + parseFloat(end); | ||
} else { | ||
end = parseFloat(end); | ||
} | ||
} | ||
// Parses relative end values with start as base (e.g.: +10, -3) | ||
if (typeof end === 'string') { | ||
// Protect against non numeric properties. | ||
if (typeof end === 'number') { | ||
object[property] = start + (end - start) * value; | ||
} | ||
} | ||
if (end.charAt(0) === '+' || end.charAt(0) === '-') { | ||
end = start + parseFloat(end); | ||
} else { | ||
end = parseFloat(end); | ||
} | ||
} | ||
this.emit('update', object, elapsed); | ||
// Protect against non numeric properties. | ||
if (typeof end === 'number') { | ||
object[property] = start + (end - start) * value; | ||
} | ||
} | ||
} | ||
if (elapsed === 1) { | ||
this.emit('update', object, elapsed); | ||
if (_repeat > 0) { | ||
if (elapsed === 1) { | ||
if (isFinite(_repeat)) { | ||
_repeat--; | ||
} | ||
if (_repeat > 0) { | ||
// Reassign starting values, restart by making startTime = now | ||
for (property in _valuesStartRepeat) { | ||
if (isFinite(_repeat)) { | ||
_repeat--; | ||
} | ||
if (typeof _valuesEnd[property] === 'string') { | ||
_valuesStartRepeat[property] = _valuesStartRepeat[property] + parseFloat(_valuesEnd[property]); | ||
} | ||
// Reassign starting values, restart by making startTime = now | ||
for (property in _valuesStartRepeat) { | ||
if (_yoyo) { | ||
var tmp = _valuesStartRepeat[property]; | ||
if (typeof _valuesEnd[property] === 'string') { | ||
_valuesStartRepeat[property] = _valuesStartRepeat[property] + parseFloat(_valuesEnd[property]); | ||
} | ||
_valuesStartRepeat[property] = _valuesEnd[property]; | ||
_valuesEnd[property] = tmp; | ||
} | ||
if (_yoyo) { | ||
var tmp = _valuesStartRepeat[property]; | ||
_valuesStart[property] = _valuesStartRepeat[property]; | ||
} | ||
_valuesStartRepeat[property] = _valuesEnd[property]; | ||
_valuesEnd[property] = tmp; | ||
} | ||
this.emit(_reversed ? 'repeat' : 'reverse', object); | ||
_valuesStart[property] = _valuesStartRepeat[property]; | ||
} | ||
if (_yoyo) { | ||
this._reversed = !_reversed; | ||
} | ||
this.emit(_reversed ? 'repeat' : 'reverse', object); | ||
if (_reversed && _repeatDelayTime) { | ||
this._startTime = time + _repeatDelayTime; | ||
} else if (!_reversed && _reverseDelayTime) { | ||
this._startTime = time + _reverseDelayTime; | ||
} else { | ||
this._startTime = time + _delayTime; | ||
} | ||
if (_yoyo) { | ||
this._reversed = !_reversed; | ||
} | ||
return true; | ||
} else { | ||
if (_reversed && _repeatDelayTime) { | ||
this._startTime = time + _repeatDelayTime; | ||
} else if (!_reversed && _reverseDelayTime) { | ||
this._startTime = time + _reverseDelayTime; | ||
} else { | ||
this._startTime = time + _delayTime; | ||
} | ||
this.emit('complete', object); | ||
return true; | ||
} else { | ||
_chainedTweens.map(function (tween) { | ||
return tween.start(_startTime + _duration); | ||
}); | ||
this.emit('complete', object); | ||
this._repeat = this._r; | ||
_chainedTweens.map(function (tween) { | ||
return tween.start(_startTime + _duration); | ||
}); | ||
return false; | ||
} | ||
} | ||
return true; | ||
this._repeat = this._r; | ||
return false; | ||
} | ||
}]); | ||
} | ||
return true; | ||
} | ||
}]); | ||
return Tween; | ||
return Tween; | ||
}(); | ||
@@ -1064,0 +1091,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.TWEEN=e():t.TWEEN=e()}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=8)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(-10*t,2)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(-Math.pow(-10*(t-1),2)+2)}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(10*(t-1),2)*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(-10*t,2)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2,t<1?-.5*Math.pow(10*(t-1),2)*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(-10*(t-1),2)*Math.sin(5*(t-1.1)*Math.PI)+1)}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?.5*(t*t*((e+1)*t-e)):.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-i.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*i.Bounce.In(2*t):.5*i.Bounce.Out(2*t-1)+.5}}};e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={Linear:function(t,e){var n=t.length-1,r=n*e,o=Math.floor(r),u=i.Utils.Linear;return e<0?u(t[0],t[1],r):e>1?u(t[n],t[n-1],n-r):u(t[o],t[o+1>n?n:o+1],r-o)},Bezier:function(t,e){for(var n=0,r=t.length-1,o=Math.pow,u=i.Utils.Bernstein,a=0;a<=r;a++)n+=o(1-e,r-a)*o(e,a)*t[a]*u(r,a);return n},CatmullRom:function(t,e){var n=t.length-1,r=n*e,o=Math.floor(r),u=i.Utils.CatmullRom;return t[0]===t[n]?(e<0&&(o=Math.floor(r=n*(1+e))),u(t[(o-1+n)%n],t[o],t[(o+1)%n],t[(o+2)%n],r-o)):e<0?t[0]-(u(t[0],t[0],t[1],t[1],-r)-t[0]):e>1?t[n]-(u(t[n],t[n],t[n-1],t[n-1],r-n)-t[n]):u(t[o?o-1:0],t[o],t[n<o+1?n:o+1],t[n<o+2?n:o+2],r-o)},Utils:{Linear:function(t,e,n){return(e-t)*n+t},Bernstein:function(t,e){var n=i.Utils.Factorial;return n(t)/n(e)/n(t-e)},Factorial:function(){var t=[1];return function(e){var n=1;if(t[e])return t[e];for(var i=e;i>1;i--)n*=i;return t[e]=n,n}}(),CatmullRom:function(t,e,n,i,r){var o=.5*(n-t),u=.5*(i-e),a=r*r,s=r*a;return(2*e-2*n+o+u)*s+(-3*e+3*n-2*o-u)*a+o*r+e}}};e.default=i},function(t,e,n){"use strict";function i(t){p(o)?(o=t,s=requestAnimationFrame(i)):(u=!1,cancelAnimationFrame(s))}Object.defineProperty(e,"__esModule",{value:!0});var r=[],o=0,u=!1,a=!1,s=void 0,c=function(){return r},h=function(t){a=t},f=function(){r=[]},l=function(t){r.push(t),a&&!u&&(i(d()),u=!0)},v=function(t){r.filter(function(e){return e!==t})},d=function(){return o},p=function(t,e){if(t=void 0!==t?t:d(),o=t,0===r.length)return!1;for(var n=0;n<r.length;)r[n].update(t)||e?n++:r.splice(n,1);return!0};e.getAll=c,e.removeAll=f,e.remove=v,e.add=l,e.now=d,e.update=p,e.autoPlay=h},function(t,e,n){"use strict";var i,r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(t){"object"===("undefined"==typeof window?"undefined":r(window))&&(i=window)}t.exports=i},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),u=(n(2),n(0)),a=i(u),s=n(1),c=i(s),h=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),this.object=e,this._valuesStart=Object.assign({},e),this._valuesStartRepeat=Object.assign({},e),this._valuesEnd={},this._chainedTweens=[],this._duration=1e3,this._easingFunction=a.default.Linear.None,this._interpolationFunction=c.default.None,this._startTime=0,this._delayTime=0,this._repeat=0,this._r=0,this._repeatDelayTime=0,this._reverseDelayTime=0,this._isPlaying=!1,this._yoyo=!1,this._reversed=!1,this._onStartCallbackFired=!1,this._events={},this._pausedTime=0,this}return o(t,[{key:"isPlaying",value:function(){return this._isPlaying}},{key:"isStarted",value:function(){return this._onStartCallbackFired}},{key:"reverse",value:function(){var t=this._valuesStartRepeat,e=this._yoyo,n=this._valuesEnd,i=this._valuesStart;for(var r in t){if("string"==typeof n[r]&&(t[r]=t[r]+parseFloat(n[r])),e){var o=t[r];t[r]=n[r],n[r]=o}i[r]=t[r]}return this._reversed=!this._reversed,this}},{key:"off",value:function(t,e){return void 0===this._events[t]?this:(void 0!==t&&void 0!==e?this._events[t].filter(function(t){return t!==e}):void 0!==t&&void 0===e&&(this._events[t]=[]),this)}},{key:"on",value:function(t,e){return void 0===this._events[t]&&(this._events[t]=[]),this._events[t].push(e),this}},{key:"once",value:function(t,e){var n=this;return void 0===this._events[t]&&(this._events[t]=[]),this.on(t,function(){for(var i=arguments.length,r=Array(i),o=0;o<i;o++)r[o]=arguments[o];e.call.apply(e,[n].concat(r)),n.off(t)})}},{key:"emit",value:function(t){for(var e=this,n=arguments.length,i=Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return void 0===this._events[t]?this:(this._events[t].map(function(t){t.call.apply(t,[e].concat(i))}),this)}},{key:"pause",value:function(){return this._isPlaying?(this._isPlaying=!1,TWEEN.remove(this),this._pausedTime=TWEEN.now(),this.emit("pause",this.object)):this}},{key:"play",value:function(){return this._isPlaying?this:(this._isPlaying=!0,this._startTime+=TWEEN.now()-this._pausedTime,TWEEN.add(this),this._pausedTime=TWEEN.now(),this.emit("play",this.object))}},{key:"restart",value:function(t){return this._startTime=TWEEN.now()+(t?0:this._delayTime),this._isPlaying||TWEEN.add(this),this.emit("restart",this._object)}},{key:"seek",value:function(t,e){return this._startTime=TWEEN.now()+Math.max(0,Math.min(t,this._duration)),this.emit("seek",t,this._object),e?this:this.pause()}},{key:"duration",value:function(t){return this._duration=t,this}},{key:"to",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;return this._valuesEnd=t,this._duration=e,this}},{key:"start",value:function(t){var e=this._startTime,n=this._delayTime;return e=void 0!==t?t:TWEEN.now(),e+=n,this._startTime=e,TWEEN.add(this),this._isPlaying=!0,this}},{key:"stop",value:function(){var t=this._isPlaying,e=(this._onStopCallback,this.object);return t?(TWEEN.remove(this),this._isPlaying=!1,this.stopChainedTweens(),this.emit("stop",e)):this}},{key:"end",value:function(){var t=this._startTime,e=this._duration;return this.update(t+e)}},{key:"stopChainedTweens",value:function(){var t=this._chainedTweens;return t.map(function(t){return t.stop()}),this}},{key:"delay",value:function(t){return this._delayTime=t,this}},{key:"repeat",value:function(t){return this._repeat=t,this._r=t,this}},{key:"repeatDelay",value:function(t){return this._repeatDelayTime=t,this}},{key:"reverseDelay",value:function(t){return this._reverseDelayTime=t,this}},{key:"yoyo",value:function(t){return this._yoyo=t,this}},{key:"easing",value:function(t){return this._easingFunction=t,this}},{key:"interpolation",value:function(t){return this._interpolationFunction=t,this}},{key:"chain",value:function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return this._chainedTweens=e,this}},{key:"update",value:function(t){var e=this._onStartCallbackFired,n=this._chainedTweens,i=this._easingFunction,r=this._interpolationFunction,o=this._repeat,u=this._repeatDelayTime,a=this._reverseDelayTime,s=this._delayTime,c=this._yoyo,h=this._reversed,f=this._startTime,l=this._duration,v=this._valuesStart,d=this._valuesStartRepeat,p=this._valuesEnd,y=this.object,_=void 0,m=void 0,w=void 0;if(t<f)return!0;e===!1&&(this.emit("start",y),this._onStartCallbackFired=!0),m=(t-f)/l,m=m>1?1:m,w=i(m);for(_ in p){var T=v[_],g=p[_];g instanceof Array?y[_]=r(g,w):("string"==typeof g&&(g="+"===g.charAt(0)||"-"===g.charAt(0)?T+parseFloat(g):parseFloat(g)),"number"==typeof g&&(y[_]=T+(g-T)*w))}if(this.emit("update",y,m),1===m){if(o>0){isFinite(o)&&o--;for(_ in d){if("string"==typeof p[_]&&(d[_]=d[_]+parseFloat(p[_])),c){var b=d[_];d[_]=p[_],p[_]=b}v[_]=d[_]}return this.emit(h?"repeat":"reverse",y),c&&(this._reversed=!h),h&&u?this._startTime=t+u:!h&&a?this._startTime=t+a:this._startTime=t+s,!0}return this.emit("complete",y),n.map(function(t){return t.start(f+l)}),this._repeat=this._r,!1}return!0}}]),t}();e.default=h},function(t,e,n){"use strict";void 0===Object.assign&&(Object.assign=function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=e.shift();return e.map(function(t){for(var e in t)i[e]=t[e]}),i})},function(t,e,n){"use strict";(function(t){var e="undefined"!=typeof window?window:"undefined"!=typeof t?t:void 0,n=["webkit","moz","ms","o"],i="AnimationFrame",r="Request"+i,o="Cancel"+i,u="CancelRequest"+i,a=setTimeout,s=clearTimeout;if(void 0===e.requestAnimationFrame){var c=void 0,h=void 0,f=Date.now(),l=50/3,v=l;n.map(function(t){void 0===(c=e[t+r])&&(c=function(t){return a(function(){h=Date.now(),t(h-f),v=l+(Date.now()-h)},v)})}),void 0!==c&&(e.requestAnimationFrame=c)}if(void 0===e.cancelAnimationFrame&&void 0===(e.cancelAnimationFrame=e.cancelRequestAnimationFrame)){var d=void 0;n.map(function(t){void 0===(d=e[t+o])&&void 0===(d=e[t+u])&&(d=function(t){return s(t)})}),void 0!==d&&(e.cancelAnimationFrame=d)}}).call(e,n(3))},function(t,e,n){"use strict";(function(t){function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var n="undefined"!=typeof window?window:"undefined"!=typeof t?t:void 0;void 0===n.Map&&(n.Map=function t(){e(this,t);var n={};return this.set=function(t,e){return n[t]=e,this},this.get=function(t){return n[t]},this.has=function(t){return void 0!==this.get(t)},this})}).call(e,n(3))},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.Interpolation=e.Easing=e.Tween=e.now=e.autoPlay=e.update=e.remove=e.removeAll=e.add=e.getAll=void 0,n(5),n(6),n(7);var r=n(2),o=n(0),u=i(o),a=n(4),s=i(a),c=n(1),h=i(c);e.getAll=r.getAll,e.add=r.add,e.removeAll=r.removeAll,e.remove=r.remove,e.update=r.update,e.autoPlay=r.autoPlay,e.now=r.now,e.Tween=s.default,e.Easing=u.default,e.Interpolation=h.default}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.TWEEN=e():t.TWEEN=e()}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=8)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(-10*t,2)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(-Math.pow(-10*(t-1),2)+2)}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(10*(t-1),2)*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(-10*t,2)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2,t<1?-.5*Math.pow(10*(t-1),2)*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(-10*(t-1),2)*Math.sin(5*(t-1.1)*Math.PI)+1)}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?.5*(t*t*((e+1)*t-e)):.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-i.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*i.Bounce.In(2*t):.5*i.Bounce.Out(2*t-1)+.5}}};e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={Linear:function(t,e){var n=t.length-1,r=n*e,o=Math.floor(r),u=i.Utils.Linear;return e<0?u(t[0],t[1],r):e>1?u(t[n],t[n-1],n-r):u(t[o],t[o+1>n?n:o+1],r-o)},Bezier:function(t,e){for(var n=0,r=t.length-1,o=Math.pow,u=i.Utils.Bernstein,a=0;a<=r;a++)n+=o(1-e,r-a)*o(e,a)*t[a]*u(r,a);return n},CatmullRom:function(t,e){var n=t.length-1,r=n*e,o=Math.floor(r),u=i.Utils.CatmullRom;return t[0]===t[n]?(e<0&&(o=Math.floor(r=n*(1+e))),u(t[(o-1+n)%n],t[o],t[(o+1)%n],t[(o+2)%n],r-o)):e<0?t[0]-(u(t[0],t[0],t[1],t[1],-r)-t[0]):e>1?t[n]-(u(t[n],t[n],t[n-1],t[n-1],r-n)-t[n]):u(t[o?o-1:0],t[o],t[n<o+1?n:o+1],t[n<o+2?n:o+2],r-o)},Utils:{Linear:function(t,e,n){return(e-t)*n+t},Bernstein:function(t,e){var n=i.Utils.Factorial;return n(t)/n(e)/n(t-e)},Factorial:function(){var t=[1];return function(e){var n=1;if(t[e])return t[e];for(var i=e;i>1;i--)n*=i;return t[e]=n,n}}(),CatmullRom:function(t,e,n,i,r){var o=.5*(n-t),u=.5*(i-e),a=r*r,s=r*a;return(2*e-2*n+o+u)*s+(-3*e+3*n-2*o-u)*a+o*r+e}}};e.default=i},function(t,e,n){"use strict";function i(t){y(o)?(o=t,s=requestAnimationFrame(i)):(u=!1,cancelAnimationFrame(s))}Object.defineProperty(e,"__esModule",{value:!0});var r=[],o=0,u=!1,a=!1,s=void 0,c=function(){return r},f=function(t){a=t},l=function(){r=[]},h=function(t){r.push(t),a&&!u&&(i(d()),u=!0)},v=function(t){r.filter(function(e){return e!==t})},d=function(){return o},y=function(t,e){if(t=void 0!==t?t:d(),o=t,0===r.length)return!1;for(var n=0;n<r.length;)r[n].update(t)||e?n++:r.splice(n,1);return!0};e.getAll=c,e.removeAll=l,e.remove=v,e.add=h,e.now=d,e.update=y,e.autoPlay=f},function(t,e,n){"use strict";var i,r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(t){"object"===("undefined"==typeof window?"undefined":r(window))&&(i=window)}t.exports=i},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),a=(n(2),n(0)),s=i(a),c=n(1),f=i(c),l=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r(this,t),this.object=e,this._valuesStart=Object.assign(t.createEmptyConst(e),e),this._valuesStartRepeat=Object.assign(t.createEmptyConst(e),e),this._valuesEnd=t.createEmptyConst(e),this._chainedTweens=[],this._duration=1e3,this._easingFunction=s.default.Linear.None,this._interpolationFunction=f.default.None,this._startTime=0,this._delayTime=0,this._repeat=0,this._r=0,this._repeatDelayTime=0,this._reverseDelayTime=0,this._isPlaying=!1,this._yoyo=!1,this._reversed=!1,this._onStartCallbackFired=!1,this._events={},this._pausedTime=0,this}return u(t,null,[{key:"createEmptyConst",value:function(t){return"number"==typeof t?0:Array.isArray(t)?[]:"object"===("undefined"==typeof t?"undefined":o(t))?{}:""}}]),u(t,[{key:"isPlaying",value:function(){return this._isPlaying}},{key:"isStarted",value:function(){return this._onStartCallbackFired}},{key:"reverse",value:function(){var t=this._valuesStartRepeat,e=this._yoyo,n=this._valuesEnd,i=this._valuesStart;for(var r in t){if("string"==typeof n[r]&&(t[r]=t[r]+parseFloat(n[r])),e){var o=t[r];t[r]=n[r],n[r]=o}i[r]=t[r]}return this._reversed=!this._reversed,this}},{key:"off",value:function(t,e){return void 0===this._events[t]?this:(void 0!==t&&void 0!==e?this._events[t].filter(function(t){return t!==e}):void 0!==t&&void 0===e&&(this._events[t]=[]),this)}},{key:"on",value:function(t,e){return void 0===this._events[t]&&(this._events[t]=[]),this._events[t].push(e),this}},{key:"once",value:function(t,e){var n=this;return void 0===this._events[t]&&(this._events[t]=[]),this.on(t,function(){for(var i=arguments.length,r=Array(i),o=0;o<i;o++)r[o]=arguments[o];e.call.apply(e,[n].concat(r)),n.off(t)})}},{key:"emit",value:function(t){for(var e=this,n=arguments.length,i=Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return void 0===this._events[t]?this:(this._events[t].map(function(t){t.call.apply(t,[e].concat(i))}),this)}},{key:"pause",value:function(){return this._isPlaying?(this._isPlaying=!1,TWEEN.remove(this),this._pausedTime=TWEEN.now(),this.emit("pause",this.object)):this}},{key:"play",value:function(){return this._isPlaying?this:(this._isPlaying=!0,this._startTime+=TWEEN.now()-this._pausedTime,TWEEN.add(this),this._pausedTime=TWEEN.now(),this.emit("play",this.object))}},{key:"restart",value:function(t){return this._startTime=TWEEN.now()+(t?0:this._delayTime),this._isPlaying||TWEEN.add(this),this.emit("restart",this._object)}},{key:"seek",value:function(t,e){return this._startTime=TWEEN.now()+Math.max(0,Math.min(t,this._duration)),this.emit("seek",t,this._object),e?this:this.pause()}},{key:"duration",value:function(t){return this._duration=t,this}},{key:"to",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;if("number"==typeof t){var n={Number:t};this._valuesEnd=n}else this._valuesEnd=t;if("number"==typeof e)this._duration=e;else if("object"===("undefined"==typeof e?"undefined":o(e)))for(var i in e)this[i](e[i]);return this}},{key:"start",value:function(t){var e=this._startTime,n=this._delayTime;return e=void 0!==t?t:TWEEN.now(),e+=n,this._startTime=e,TWEEN.add(this),this._isPlaying=!0,this}},{key:"stop",value:function(){var t=this._isPlaying,e=(this._onStopCallback,this.object);return t?(TWEEN.remove(this),this._isPlaying=!1,this.stopChainedTweens(),this.emit("stop",e)):this}},{key:"end",value:function(){var t=this._startTime,e=this._duration;return this.update(t+e)}},{key:"stopChainedTweens",value:function(){var t=this._chainedTweens;return t.map(function(t){return t.stop()}),this}},{key:"delay",value:function(t){return this._delayTime=t,this}},{key:"repeat",value:function(t){return this._repeat=t,this._r=t,this}},{key:"repeatDelay",value:function(t){return this._repeatDelayTime=t,this}},{key:"reverseDelay",value:function(t){return this._reverseDelayTime=t,this}},{key:"yoyo",value:function(t){return this._yoyo=t,this}},{key:"easing",value:function(t){return this._easingFunction=t,this}},{key:"interpolation",value:function(t){return this._interpolationFunction=t,this}},{key:"chain",value:function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];return this._chainedTweens=e,this}},{key:"get",value:function(t){return this.update(t),this._object}},{key:"update",value:function(t){var e=this._onStartCallbackFired,n=this._chainedTweens,i=this._easingFunction,r=this._interpolationFunction,o=this._repeat,u=this._repeatDelayTime,a=this._reverseDelayTime,s=this._delayTime,c=this._yoyo,f=this._reversed,l=this._startTime,h=this._duration,v=this._valuesStart,d=this._valuesStartRepeat,y=this._valuesEnd,p=this.object,_=void 0,m=void 0,b=void 0;if(t<l)return!0;e===!1&&(this.emit("start",p),this._onStartCallbackFired=!0),m=(t-l)/h,m=m>1?1:m,b=i(m);for(_ in y){var w=v[_],T=y[_];T instanceof Array?p[_]=r(T,b):("string"==typeof T&&(T="+"===T.charAt(0)||"-"===T.charAt(0)?w+parseFloat(T):parseFloat(T)),"number"==typeof T&&(p[_]=w+(T-w)*b))}if(this.emit("update",p,m),1===m){if(o>0){isFinite(o)&&o--;for(_ in d){if("string"==typeof y[_]&&(d[_]=d[_]+parseFloat(y[_])),c){var g=d[_];d[_]=y[_],y[_]=g}v[_]=d[_]}return this.emit(f?"repeat":"reverse",p),c&&(this._reversed=!f),f&&u?this._startTime=t+u:!f&&a?this._startTime=t+a:this._startTime=t+s,!0}return this.emit("complete",p),n.map(function(t){return t.start(l+h)}),this._repeat=this._r,!1}return!0}}]),t}();e.default=l},function(t,e,n){"use strict";void 0===Object.assign&&(Object.assign=function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=e.shift();return e.map(function(t){for(var e in t)i[e]=t[e]}),i})},function(t,e,n){"use strict";(function(t){var e="undefined"!=typeof window?window:"undefined"!=typeof t?t:void 0,n=["webkit","moz","ms","o"],i="AnimationFrame",r="Request"+i,o="Cancel"+i,u="CancelRequest"+i,a=setTimeout,s=clearTimeout;if(void 0===e.requestAnimationFrame){var c=void 0,f=void 0,l=Date.now(),h=50/3,v=h;n.map(function(t){void 0===(c=e[t+r])&&(c=function(t){return a(function(){f=Date.now(),t(f-l),v=h+(Date.now()-f)},v)})}),void 0!==c&&(e.requestAnimationFrame=c)}if(void 0===e.cancelAnimationFrame&&void 0===(e.cancelAnimationFrame=e.cancelRequestAnimationFrame)){var d=void 0;n.map(function(t){void 0===(d=e[t+o])&&void 0===(d=e[t+u])&&(d=function(t){return s(t)})}),void 0!==d&&(e.cancelAnimationFrame=d)}}).call(e,n(3))},function(t,e,n){"use strict";(function(t){function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var n="undefined"!=typeof window?window:"undefined"!=typeof t?t:void 0;void 0===n.Map&&(n.Map=function t(){e(this,t);var n={};return this.set=function(t,e){return n[t]=e,this},this.get=function(t){return n[t]},this.has=function(t){return void 0!==this.get(t)},this})}).call(e,n(3))},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.Interpolation=e.Easing=e.Tween=e.now=e.autoPlay=e.update=e.remove=e.removeAll=e.add=e.getAll=void 0,n(5),n(6),n(7);var r=n(2),o=n(0),u=i(o),a=n(4),s=i(a),c=n(1),f=i(c);e.getAll=r.getAll,e.add=r.add,e.removeAll=r.removeAll,e.remove=r.remove,e.update=r.update,e.autoPlay=r.autoPlay,e.now=r.now,e.Tween=s.default,e.Easing=u.default,e.Interpolation=f.default}])}); |
{ | ||
"name": "es6-tween", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "ES6 implementation of amazing tween.js", | ||
@@ -5,0 +5,0 @@ "main": "dist/Tween.js", |
@@ -11,8 +11,11 @@ import { | ||
class Tween { | ||
static createEmptyConst (oldObject) { | ||
return typeof(oldObject) === "number" ? 0 : Array.isArray(oldObject) ? [] : typeof(oldObject) === "object" ? {} : ''; | ||
} | ||
constructor( object = {} ) { | ||
this.object = object; | ||
this._valuesStart = Object.assign( {}, object ); | ||
this._valuesStartRepeat = Object.assign( {}, object ); | ||
this._valuesEnd = {}; | ||
this._valuesStart = Object.assign( Tween.createEmptyConst(object), object ); | ||
this._valuesStartRepeat = Object.assign( Tween.createEmptyConst(object), object ); | ||
this._valuesEnd = Tween.createEmptyConst(object); | ||
this._chainedTweens = []; | ||
@@ -177,5 +180,17 @@ | ||
this._valuesEnd = properties; | ||
this._duration = duration; | ||
if ( typeof properties === "number" ) { | ||
let _vE = { Number: properties }; | ||
this._valuesEnd = _vE; | ||
} else { | ||
this._valuesEnd = properties; | ||
} | ||
if ( typeof duration === "number" ) { | ||
this._duration = duration; | ||
} else if ( typeof duration === "object" ) { | ||
for ( let prop in duration ) { | ||
this[prop](duration[prop]); | ||
} | ||
} | ||
return this; | ||
@@ -300,2 +315,6 @@ | ||
} | ||
get ( time ) { | ||
this.update( time ); | ||
return this._object; | ||
} | ||
update( time ) { | ||
@@ -302,0 +321,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
333020
1702