diff --git a/build/tina.js b/build/tina.js index 88442db..e96023a 100644 --- a/build/tina.js +++ b/build/tina.js @@ -1,9 +1,9 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o Using linear easing + // 1 => Using custom easing + var easingFlag; + if (easing) { + easingFlag = 1; + this.easing = easing; + this.easingParam = easingParam; + } else { + easingFlag = 0; + } + + // Interpolation flag - Whether an interpolation function is used + // 0 => No Interpolation + // 1 => At least one interpolation + var interpFlag; + if (interpolations === null) { + interpFlag = 0; + } else { + interpFlag = 1; + this.interps = interpolations; + this.interpParams = interpolationParams || {}; + } + + // Property flag - Whether the transition has several properties + // 0 => Only one property + // 1 => Several properties + var propsFlag; + if (properties.length === 1) { + propsFlag = 0; + this.prop = properties[0]; // string + this.props = null; + } else { + propsFlag = 1; + this.prop = null; + this.props = properties; // array + } + + this.update = updateMethods[easingFlag][interpFlag][propsFlag]; +} + +module.exports = TransitionCSS; + +},{"./CSSMap":5}],20:[function(require,module,exports){ // One property function update(object, t) { @@ -2824,7 +3034,7 @@ function Transition(properties, from, to, start, duration, easing, easingParam, } module.exports = Transition; -},{}],18:[function(require,module,exports){ +},{}],21:[function(require,module,exports){ var BriefPlayable = require('./BriefPlayable'); var AbstractTween = require('./AbstractTween'); @@ -2867,7 +3077,7 @@ Tween.prototype.wait = function (duration) { } return this; }; -},{"./AbstractTween":1,"./BriefPlayable":3,"./inherit":22}],19:[function(require,module,exports){ +},{"./AbstractTween":1,"./BriefPlayable":3,"./inherit":25}],22:[function(require,module,exports){ var Player = require('./Player'); var TINA = require('./TINA'); @@ -2894,7 +3104,7 @@ Tweener.prototype.useAsDefault = function () { TINA.setDefaultTweener(this); return this; }; -},{"./Player":9,"./TINA":12}],20:[function(require,module,exports){ +},{"./Player":11,"./TINA":14}],23:[function(require,module,exports){ /** * * @file A set of ease functions @@ -3157,10 +3367,10 @@ exports.backInOut = function (t, e) { return 0.5 * (t * t * ((e + 1) * t + e)) + 1; }; -},{}],21:[function(require,module,exports){ +},{}],24:[function(require,module,exports){ var TINA = require('./TINA.js'); -// TINA.CSSTween = require('./CSSTween'); +TINA.CSSTween = require('./CSSTween'); TINA.Delay = require('./Delay'); TINA.BriefExtension = require('./BriefExtension'); TINA.BriefPlayable = require('./BriefPlayable'); @@ -3181,7 +3391,7 @@ TINA.Tweener = require('./Tweener'); module.exports = TINA; -},{"./BriefExtension":2,"./BriefPlayable":3,"./BriefPlayer":4,"./Delay":5,"./NestedTween":7,"./Playable":8,"./Player":9,"./Recorder":10,"./Sequence":11,"./TINA.js":12,"./Ticker":13,"./Timeline":14,"./Timer":15,"./Tween":18,"./Tweener":19,"./easing":20,"./interpolation":23}],22:[function(require,module,exports){ +},{"./BriefExtension":2,"./BriefPlayable":3,"./BriefPlayer":4,"./CSSTween":6,"./Delay":7,"./NestedTween":9,"./Playable":10,"./Player":11,"./Recorder":12,"./Sequence":13,"./TINA.js":14,"./Ticker":15,"./Timeline":16,"./Timer":17,"./Tween":21,"./Tweener":22,"./easing":23,"./interpolation":26}],25:[function(require,module,exports){ module.exports = function (subobject, superobject) { var prototypes = Object.keys(superobject.prototype); for (var p = 0; p < prototypes.length; p += 1) { @@ -3189,7 +3399,7 @@ module.exports = function (subobject, superobject) { subobject.prototype[prototypeName] = superobject.prototype[prototypeName]; } }; -},{}],23:[function(require,module,exports){ +},{}],26:[function(require,module,exports){ /** * * @file A set of interpolation functions @@ -3681,4 +3891,4 @@ exports.simplex2d = (function () { return a * (1 - t) + b * t; }; })(); -},{}]},{},[21]); +},{}]},{},[24]); diff --git a/build/tina.min.js b/build/tina.min.js index d18fb18..2cf9385 100644 --- a/build/tina.min.js +++ b/build/tina.min.js @@ -1,71 +1,80 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o0&&(this._transitions[0].from=t),this},AbstractTween.prototype._setFrom=function(){this._from={};for(var t=0;t0?this._relative===!0?this._setFrom():this._transitions[this._transitions.length-1].to:null===this._from?this._setFrom():this._from},AbstractTween.prototype.to=function(t,i,n,s,e){"string"==typeof n&&(void 0===easingFunctions[n]?(console.warn("[AbstractTween.to] Given easing does not exist"),n=void 0):n=easingFunctions[n]);var r=this._getLastTransitionEnding(),o=this._relative===!0?TransitionRelative:Transition,a=new o(this._properties,r,t,this._duration,i,n,s,this._interpolations,e);return this._transitions.push(a),this._duration+=i,this},AbstractTween.prototype.wait=function(t){var i=this._getLastTransitionEnding();return this._transitions.push(new Temporisation(this._duration,t,i,this._properties)),this._duration+=t,this},AbstractTween.prototype._update=function(){for(var t=this._transitions[this._index];t.end<=this._time;){if(this._index===this._transitions.length-1)return void t.update(this._object,1);this._relative===!0&&t.update(this._object,1),t=this._transitions[++this._index]}for(;this._time<=t.start;){if(0===this._index)return void t.update(this._object,0);this._relative===!0&&t.update(this._object,0),t=this._transitions[--this._index]}t.update(this._object,(this._time-t.start)/t.duration)},AbstractTween.prototype._validate=function(){return 0===this._transitions.length?(console.warn("[AbstractTween._validate] Cannot start a tween with no transition:",this),!1):!0}; +function Temporisation(t,i,n,s){this.start=t,this.end=t+i,this.duration=i,this.properties=s,this.to=n}function AbstractTween(t,i){if(this._object=t,(null===i||void 0===i)&&t instanceof Array){i=[];for(var n=0;n0&&(this._transitions[0].from=t),this},AbstractTween.prototype._setFrom=function(){this._from={};for(var t=0;t0?this._relative===!0?this._setFrom():this._transitions[this._transitions.length-1].to:null===this._from?this._setFrom():this._from},AbstractTween.prototype.to=function(t,i,n,s,e){"string"==typeof n&&(void 0===easingFunctions[n]?(console.warn("[AbstractTween.to] Given easing does not exist"),n=void 0):n=easingFunctions[n]);var r=this._getLastTransitionEnding(),o=null;o=this._relative===!0?TransitionRelative:this._css===!0?TransitionCSS:Transition;var a=new o(this._properties,r,t,this._duration,i,n,s,this._interpolations,e);return this._transitions.push(a),this._duration+=i,this},AbstractTween.prototype.wait=function(t){var i=this._getLastTransitionEnding();return this._transitions.push(new Temporisation(this._duration,t,i,this._properties)),this._duration+=t,this},AbstractTween.prototype._update=function(){for(var t=this._transitions[this._index];t.end<=this._time;){if(this._index===this._transitions.length-1)return void t.update(this._object,1);this._relative===!0&&t.update(this._object,1),t=this._transitions[++this._index]}for(;this._time<=t.start;){if(0===this._index)return void t.update(this._object,0);this._relative===!0&&t.update(this._object,0),t=this._transitions[--this._index]}t.update(this._object,(this._time-t.start)/t.duration)},AbstractTween.prototype._validate=function(){return 0===this._transitions.length?(console.warn("[AbstractTween._validate] Cannot start a tween with no transition:",this),!1):!0}; -},{"./Transition":16,"./TransitionRelative":17,"./easing":20,"./interpolation":23}],2:[function(require,module,exports){ +},{"./Transition":18,"./TransitionCSS":19,"./TransitionRelative":20,"./easing":23,"./interpolation":26}],2:[function(require,module,exports){ function BriefExtension(){this._duration=0,this._onComplete=null,this._iterations=1,this._pingpong=!1,this._persist=!1}module.exports=BriefExtension,BriefExtension.prototype.setSpeed=function(t){0===t?0!==this._speed&&(this._startTime+=this._time/this._speed-this._time):0===this._speed?this._startTime+=this._time-this._time/t:this._startTime+=this._time/this._speed-this._time/t,this._speed=t,null!==this._player&&this._player._onPlayableChanged(this)},BriefExtension.prototype.onComplete=function(t){return this._onComplete=t,this},BriefExtension.prototype.getDuration=function(){return this._duration*this._iterations/this._speed},BriefExtension.prototype._setDuration=function(t){this._duration=t,null!==this._player&&this._player._onPlayableChanged(this)},BriefExtension.prototype._extendDuration=function(t){this._duration+=t,null!==this._player&&this._player._onPlayableChanged(this)},BriefExtension.prototype._getEndTime=function(){return this._speed>0?this._startTime+this.getDuration():this._speed<0?this._startTime:1/0},BriefExtension.prototype._setStartTime=function(t){this._speed>0?this._startTime=t:this._speed<0?this._startTime=t-this.getDuration():this._startTime=1/0},BriefExtension.prototype._getStartTime=function(){return this._speed>0?this._startTime:this._speed<0?this._startTime+this.getDuration():-(1/0)},BriefExtension.prototype._isTimeWithin=function(t){return this._speed>0?this._startTime0?(this._startTime-i)*(this._startTime+this.getDuration()-t)<=0:this._speed<0?(this._startTime+this.getDuration()-i)*(this._startTime-t)<=0:!0},BriefExtension.prototype.goToEnd=function(){return this.goTo(this.getDuration(),this._iterations-1)},BriefExtension.prototype.loop=function(){return this.iterations(1/0)},BriefExtension.prototype.iterations=function(t){return 0>t?(console.warn("[BriefExtension.iterations] Number of iterations cannot be negative"),this):(this._iterations=t,null!==this._player&&this._player._onPlayableChanged(this),this)},BriefExtension.prototype.persist=function(t){return this._persist=t,this},BriefExtension.prototype.pingpong=function(t){return this._pingpong=t,null!==this._player&&this._player._onPlayableChanged(this),this},BriefExtension.prototype._complete=function(t){return this._persist===!0?(this._startTime+=t,void this._player._onPlayableChanged(this)):this._player._inactivate(this)===!1?this:void(null!==this._onComplete&&this._onComplete(t))};var epsilon=1e-6;BriefExtension.prototype._moveTo=function(t,i,e){i*=this._speed;var s;if(0!==i)if(1===this._iterations)this._time=(t-this._startTime)*this._speed,i>0?this._time>=this._duration?(s=this._time-this._duration,this._time=this._duration):this._time<0:0>i&&this._time<=0&&(s=this._time,this._time=0);else{t=(t-this._startTime)*this._speed;var n=t/this._duration;i>0?n>0&&ni&&(n>0&&n0&&this.duration-this._timei&&this._timei&&(i=t);for(e=this._inactivePlayables.first;null!==e;e=e.next)r=e.object,t=r._getStartTime()+r.getDuration(),t>i&&(i=t);this._setDuration(i)},BriefPlayer.prototype._onPlayableChanged=BriefPlayer.prototype._updateDuration,BriefPlayer.prototype._onPlayableRemoved=BriefPlayer.prototype._updateDuration; -},{"./BriefExtension":2,"./Player":9,"./inherit":22}],5:[function(require,module,exports){ +},{"./BriefExtension":2,"./Player":11,"./inherit":25}],5:[function(require,module,exports){ +module.exports=function(t){for(var p={height:"px",width:"px",top:"px",left:"px",bottom:"px",right:"px",opacity:""},o={},i=0;iw;w+=1)_=_[p[w]];r=p[a],_[r]instanceof Array?(i[h]=null,s[h]=_[r],this._propertyChainStrings.push(h),this._propertyChains[h]=p):(i[n]=[r],s[n]=_,this._propertyChainStrings.push(n),p.pop(),this._propertyChains[n]=p)}else r=h.substring(h.lastIndexOf(".")+1),i[n].push(r)}for(n in s){var f=s[n],l=i[n],u=new AbstractTween(f,l);this._tweens.push(u),this._tweensPerObject[n]=u}}var BriefPlayable=require("./BriefPlayable"),AbstractTween=require("./AbstractTween");NestedTween.prototype=Object.create(BriefPlayable.prototype),NestedTween.prototype.constructor=NestedTween,module.exports=NestedTween,NestedTween.prototype.relative=function(e){for(var t=0;to&&void 0!==i;o+=1)i=i[n[o]];void 0!==i&&this._tweensPerObject[r].interpolations(i)}return this},NestedTween.prototype.from=function(e){for(var t=0;to&&void 0!==i;o+=1)i=i[n[o]];void 0!==i&&this._tweensPerObject[r].from(i)}return this},NestedTween.prototype.to=function(e,t,r,n,s){for(var i=0;i_;_+=1)a=a[h[_]];var w=s;for(_=0;p>_&&void 0!==w;_+=1)w=w[h[_]];this._tweensPerObject[o].to(a,t,r,n,w)}return this._extendDuration(t),this},NestedTween.prototype.wait=function(e){for(var t=0;tt?void console.warn("[Playable.speed] This playable cannot have negative speed"):(0===t?0!==this._speed&&(this._startTime+=this._time/this._speed-this._time):0===this._speed?this._startTime+=this._time-this._time/t:this._startTime+=this._time/this._speed-this._time/t,this._speed=t,void(null!==this._player&&this._player._onPlayableChanged(this)))},Playable.prototype.goTo=function(t,e){return 1===this._iterations?0===this._speed?this._startTime+=this._time-t:this._startTime+=(this._time-t)/this._speed:(e=e||0,0===this._speed?this._startTime+=this._time-t-e*this._duration:this._startTime+=(this._time-t-e*this._duration)/this._speed),this._time=t,null!==this._player&&this._player._onPlayableChanged(this),this},Playable.prototype.goToBeginning=function(){return this.goTo(0,0)},Playable.prototype.getDuration=function(){return 1/0},Playable.prototype._getEndTime=function(){return 1/0},Playable.prototype._setStartTime=function(t){this._startTime=t},Playable.prototype._getStartTime=function(){return this._startTime},Playable.prototype._isWithin=function(t){return this._startTimet?void console.warn("[Playable.speed] This playable cannot have negative speed"):(0===t?0!==this._speed&&(this._startTime+=this._time/this._speed-this._time):0===this._speed?this._startTime+=this._time-this._time/t:this._startTime+=this._time/this._speed-this._time/t,this._speed=t,void(null!==this._player&&this._player._onPlayableChanged(this)))},Playable.prototype.goTo=function(t,e){return 1===this._iterations?0===this._speed?this._startTime+=this._time-t:this._startTime+=(this._time-t)/this._speed:(e=e||0,0===this._speed?this._startTime+=this._time-t-e*this._duration:this._startTime+=(this._time-t-e*this._duration)/this._speed),this._time=t,null!==this._player&&this._player._onPlayableChanged(this),this},Playable.prototype.goToBeginning=function(){return this.goTo(0,0)},Playable.prototype.getDuration=function(){return 1/0},Playable.prototype._getEndTime=function(){return 1/0},Playable.prototype._setStartTime=function(t){this._startTime=t},Playable.prototype._getStartTime=function(){return this._startTime},Playable.prototype._isWithin=function(t){return this._startTime0;){var e=this._playablesToRemove.pop(),a=e.object;a._handle=this._activePlayables.removeByReference(e)}0===this._activePlayables.length&&0===this._inactivePlayables.length&&this._onAllPlayablesRemoved()},Player.prototype.clear=function(){return this._activePlayables.clear(),this._inactivePlayables.clear(),this._playablesToRemove.clear(),this._controls.clear(),this},Player.prototype._warn=function(e){this._silent===!1&&console.warn(e),this._debug===!0},Player.prototype.silent=function(e){return this._silent=e||!1,this},Player.prototype.debug=function(e){return this._debug=e||!1,this},Player.prototype.stop=function(){for(var e=this._activePlayables.first;null!==e;){var a=e.next,t=e.object;t.stop(),e=a}this._handlePlayablesToRemove(),Playable.prototype.stop.call(this)},Player.prototype._activate=function(e){this._inactivePlayables.removeByReference(e._handle),e._handle=this._activePlayables.addBack(e)},Player.prototype._inactivate=function(e){return null===e._handle?void this._warn("[Playable.stop] Cannot stop a playable that is not running"):(this._activePlayables.removeByReference(e._handle),void(e._handle=this._inactivePlayables.addBack(e)))},Player.prototype._updatePlayableList=function(e){this._handlePlayablesToRemove();var a,t;e>0?(a=this._time-e,t=this._time):(a=this._time,t=this._time-e);for(var l=this._inactivePlayables.first;null!==l;){var i=l.object;l=l.next,i._overlaps(a,t)&&(this._activate(i),i._start())}},Player.prototype._update=function(e,a){this._updatePlayableList(e);for(var t=this._activePlayables.first;null!==t;t=t.next)void 0===a?t.object._moveTo(this._time,e):t.object._moveTo(this._time,e,a)},Player.prototype._onPlayableChanged=function(){},Player.prototype._onPlayableRemoved=function(){},Player.prototype._onAllPlayablesRemoved=function(){}; -},{"./DoublyList":6,"./Playable":8}],10:[function(require,module,exports){ +},{"./DoublyList":8,"./Playable":10}],12:[function(require,module,exports){ function Record(t,e){this.time=t,this.values=e}function ObjectRecorder(t,e,r,i){this.object=t,this.properties=e,this.records=new DoublyList,this.currentRecord=null,this.isIn=!1,this.onIn=r||null,this.onOut=i||null}function Recorder(t){return this instanceof Recorder==!1?new Recorder:(BriefPlayable.call(this),this._duration=1/0,this._slackTime=0,this._maxRecordingDuration=t||1/0,this._recordedObjects=[],this._recordingObjects={},this._recordingObjectLabels=[],this._recording=!0,this._playing=!1,this._smooth=!1,this._onStartRecording=null,this._onStopRecording=null,this._onStartPlaying=null,void(this._onStopPlaying=null))}var BriefPlayable=require("./BriefPlayable"),DoublyList=require("./DoublyList");ObjectRecorder.prototype.erase=function(t,e){if(t>e){var r=t;t=e,e=r}var i=this.records.last;if(i.object.time<=e){for(;null!==i&&i.object.time>=t;){var o=i.previous;this.records.removeBeReference(i),i=o}return void(null===this.currentRecord.container&&(this.currentRecord=i))}for(var n=this.records.first;null!==n&&n.object.time<=e;){var s=n.next;n.object.time>=t&&this.records.removeBeReference(n),n=s}null===this.currentRecord.container&&(this.currentRecord=n)},ObjectRecorder.prototype.record=function(t,e){if(0!==e||null===this.currentRecord||this.currentRecord.time!==t){for(var r=[],i=0;il;l+=1)this.object[this.properties[l]]=_[l]*b+g[l]*j}else{var y=this.currentRecord.object.values;for(l=0;n>l;l+=1)this.object[this.properties[l]]=y[l]}o===!1&&null!==this.onOut&&this.onOut()},Recorder.prototype=Object.create(BriefPlayable.prototype),Recorder.prototype.constructor=Recorder,module.exports=Recorder,Recorder.prototype.getDuration=function(){var t;return t=this._playing===!0?this._time>this._maxRecordingDuration?this._maxRecordingDuration:this._time:1/0,t*this._iterations/this._speed},Recorder.prototype.smooth=function(t){return this._smooth=t,this},Recorder.prototype.onStartRecording=function(t){return this._onStartRecording=t,this},Recorder.prototype.onStopRecording=function(t){return this._onStopRecording=t,this},Recorder.prototype.onStartPlaying=function(t){return this._onStartPlaying=t,this},Recorder.prototype.onStopPlaying=function(t){return this._onStopPlaying=t,this},Recorder.prototype.reset=function(){return this._recordedObjects=[],this._recordingObjects={},this._recordingObjectLabels=[],this},Recorder.prototype.record=function(t,e,r,i,o){var n=new ObjectRecorder(e,r,i,o);return this._recordingObjects[t]=n,this._recordedObjects.push(n),this._recordingObjectLabels.push(t),this},Recorder.prototype.stopRecordingObject=function(t){delete this._recordingObjects[t];var e=this._recordingObjectLabels.indexOf(t);return-1===e?(console.warn("[Recorder.stopRecordingObject] Trying to stop recording an object that is not being recording:",t),this):(this._recordingObjectLabels.splice(e,1),this)},Recorder.prototype.removeRecordedObject=function(t){var e=this._recordingObjects[t];delete this._recordingObjects[t];var r=this._recordingObjectLabels.indexOf(t);-1!==r&&this._recordingObjectLabels.splice(r,1);var i=this._recordedObjects.indexOf(e);return-1===i?(console.warn("[Recorder.removeRecordedObject] Trying to remove an object that was not recorded:",t),this):(this._recordingObjectLabels.splice(i,1),this)},Recorder.prototype.recording=function(t){return this._recording!==t&&(this._recording=t,this._recording===!0?(this._playing===!0&&(null!==this._onStopPlaying&&this._onStopPlaying(),this._playing=!1),this._duration=1/0,null!==this._player&&this._player._onPlayableChanged(this),null!==this._onStartRecording&&this._onStartRecording()):null!==this._onStopRecording&&this._onStopRecording()),this},Recorder.prototype.playing=function(t){return this._playing!==t&&(this._playing=t,this._playing===!0?(this._recording===!0&&(null!==this._onStopRecording&&this._onStopRecording(),this._recording=!1),this._duration=this._time,this.goToBeginning(this._startTime+this.getDuration()),null!==this._onStartPlaying&&this._onStartPlaying()):null!==this._onStopPlaying&&this._onStopPlaying()),this},Recorder.prototype._update=function(t){var e,r=this._slackTime+this._time;if(this._recording===!0){var i,o;t>0?(i=this._time-this._maxRecordingDuration,o=i>0):(i=this._time,o=0>i);var n=this._recordingObjectLabels.length;for(e=0;n>e;e+=1){var s=this._recordingObjectLabels[e],c=this._recordingObjects[s];c.record(r,t),o===!0&&c.erase(0,i)}i>0&&(this._slackTime+=i,this._setStartTime(this._startTime+i),this._player._onPlayableChanged(this))}else if(this._playing===!0){var h=this._recordedObjects.length;for(e=0;h>e;e+=1)this._recordedObjects[e].play(r,t,this._smooth)}}; -},{"./BriefPlayable":3,"./DoublyList":6}],11:[function(require,module,exports){ +},{"./BriefPlayable":3,"./DoublyList":8}],13:[function(require,module,exports){ function Sequence(){return this instanceof Sequence==!1?new Sequence:(this._sequencedPlayables=new DoublyList,void Timeline.call(this))}var Timeline=require("./Timeline"),Delay=require("./Delay"),DoublyList=require("./DoublyList");Sequence.prototype=Object.create(Timeline.prototype),Sequence.prototype.constructor=Sequence,module.exports=Sequence,Sequence.prototype.add=function(e){return this._sequencedPlayables.addBack(e),Timeline.prototype.add.call(this,e,this._duration)},Sequence.prototype.addDelay=function(e){return this.add(new Delay(e))},Sequence.prototype._reconstruct=function(){var e,t,n=this._activePlayables.first;null!==n&&(e=n.object,t=this._time-e._getStartTime());for(var i=0,s=this._sequencedPlayables.first;null!==s;s=s.next){var a=s.object;a._setStartTime(i),i=a._getEndTime()}if(null!==n){var r=(this._getStartTime(),this._time-e._getStartTime()),u=t-r;this._startTime+=u}this._duration=i,null!==this._player&&this._player._onPlayableChanged(this)},Sequence.prototype.substitute=function(e,t){if(0===this._sequencedPlayables.length)return void this._warn("[Sequence.substitute] The sequence is empty!");var n=this._sequencedPlayables.getNode(e);this._sequencedPlayables.addAfter(n,t),this._add(t),this.remove(e)},Sequence.prototype._onPlayableRemoved=function(e){this._sequencedPlayables.remove(e),0!==this._sequencedPlayables.length&&this._reconstruct()},Sequence.prototype._onPlayableChanged=Sequence.prototype._reconstruct; -},{"./Delay":5,"./DoublyList":6,"./Timeline":14}],12:[function(require,module,exports){ +},{"./Delay":7,"./DoublyList":8,"./Timeline":16}],14:[function(require,module,exports){ (function (global){ var DoublyList=require("./DoublyList"),root;"undefined"!=typeof window?root=window:"undefined"!=typeof global?root=global:(console.warn("[TINA] Your environment might not support TINA."),root=this);var requestAnimFrame=function(){return root.requestAnimationFrame||root.webkitRequestAnimationFrame||root.mozRequestAnimationFrame||root.oRequestAnimationFrame||root.msRequestAnimationFrame||function(e){root.setTimeout(e,1e3/60)}}(),clock=root.performance||Date,TINA={_activeTweeners:new DoublyList,_inactiveTweeners:new DoublyList,_tweenersToRemove:new DoublyList,_defaultTweener:null,_startTime:0,_time:0,_running:!1,_onStart:null,_onPause:null,_onResume:null,_onUpdate:null,_onStop:null,_pauseOnLostFocus:!1,_pauseOnLostFocusInitialised:!1,onStart:function(e){return this._onStart=e,this},onUpdate:function(e){return this._onUpdate=e,this},onStop:function(e){return this._onStop=e,this},onPause:function(e){return this._onPause=e,this},isRunning:function(){return this._running===!0},update:function(){var e=clock.now()-this._startTime,t=e-this._time;for(0>t?(t=1,this._startTime-=1,this._time+=1):this._time=e;this._tweenersToRemove.length>0;){var n=this._tweenersToRemove.pop();n._handle=this._activeTweeners.removeByReference(n._handle)}for(;this._inactiveTweeners.length>0;){var i=this._inactiveTweeners.pop();i._handle=this._activeTweeners.addBack(i),i._start()}for(var s=this._activeTweeners.first;null!==s;s=s.next)s.object._moveTo(this._time,t);null!==this._onUpdate&&this._onUpdate(this._time,t)},reset:function(){var e=clock.now(),t=e-this._time;this._startTime+=t,this._time=0},start:function(){if(this._startAutomaticUpdate()!==!1){for(null!==this._onStart&&this._onStart();this._inactiveTweeners.length>0;){var e=this._inactiveTweeners.first;this._activate(e.object)}return this}},stop:function(){if(this._stopAutomaticUpdate()!==!1){for(;this._activePlayables.length>0;){var e=this._activePlayables.first;e.object.stop()}return null!==this._onStop&&this._onStop(),this}},_startAutomaticUpdate:function(){function e(){TINA._running===!0&&(TINA.update(),requestAnimFrame(e))}return this._running===!0?(console.warn("[TINA.start] TINA is already running"),!1):(this.reset(),this._running=!0,requestAnimFrame(e),!0)},_stopAutomaticUpdate:function(){return this._running===!1?(console.warn("[TINA.pause] TINA is not running"),!1):(this._running=!1,!0)},pause:function(){if(this._stopAutomaticUpdate()!==!1){for(var e=this._activeTweeners.first;null!==e;e=e.next)e.object._pause();return null!==this._onPause&&this._onPause(),this}},resume:function(){if(this._startAutomaticUpdate()!==!1){null!==this._onResume&&this._onResume();for(var e=this._activeTweeners.first;null!==e;e=e.next)e.object._resume();return this}},_initialisePauseOnLostFocus:function(){if(this._pauseOnLostFocusInitialised!==!0){if(void 0===document)return void console.warn("[TINA.pauseOnLostFocus] Cannot pause on lost focus because TINA is not running in a webpage (node.js does not allow this functionality)");var e,t;if("undefined"!=typeof document.hidden?(e="hidden",t="visibilitychange"):"undefined"!=typeof document.mozHidden?(e="mozHidden",t="mozvisibilitychange"):"undefined"!=typeof document.msHidden?(e="msHidden",t="msvisibilitychange"):"undefined"!=typeof document.webkitHidden&&(e="webkitHidden",t="webkitvisibilitychange"),"undefined"==typeof document[e])return void console.warn("[Tweener] Cannot pause on lost focus because the browser does not support the Page Visibility API");this._pauseOnLostFocusInitialised=!0;var n=!1;document.addEventListener(t,function(){document[e]&&(n=TINA.isRunning(),n&&TINA._pauseOnLostFocus&&TINA.pause()),document[e]||n&&TINA._pauseOnLostFocus&&TINA.resume()},!1)}},pauseOnLostFocus:function(e){return e===!0&&this._pauseOnLostFocusInitialised===!1&&this._initialisePauseOnLostFocus(),this._pauseOnLostFocus=e,this},_add:function(e){return this._running===!1&&this.start(),null===e._handle?(e._handle=this._inactiveTweeners.add(e),void(e._player=this)):e._handle.container===this._tweenersToRemove?void(e._handle=this._tweenersToRemove.removeByReference(e._handle)):void 0},add:function(e){return this._add(e),this},_inactivate:function(e){null!==e._handle&&this._activePlayables.removeByReference(e._handle),e._handle=this._inactivePlayables.addBack(e)},_remove:function(e){return null!==e._handle?e._handle.container===this._activeTweeners?void(e._handle=this._tweenersToRemove.add(e._handle)):e._handle.container===this._inactiveTweeners?void(e._handle=this._inactiveTweeners.removeByReference(e._handle)):void 0:void 0},remove:function(e){return this._remove(e),this},setDefaultTweener:function(e){return this._defaultTweener=e,this},getDefaultTweener:function(){if(null===this._defaultTweener){var e=this.Timer;this._defaultTweener=new e}return this._defaultTweener},_startDefaultTweener:function(){var e=this.getDefaultTweener();return this._add(e),e}};module.exports=root.TINA=TINA; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./DoublyList":6}],13:[function(require,module,exports){ +},{"./DoublyList":8}],15:[function(require,module,exports){ function Ticker(t){return this instanceof Ticker==!1?new Ticker(t):(Tweener.call(this),void(this.tupt=t||1))}var Tweener=require("./Tweener");Ticker.prototype=Object.create(Tweener.prototype),Ticker.prototype.constructor=Ticker,module.exports=Ticker,Ticker.prototype._moveTo=function(t,e){this._time+=this.tupt,e=this.tupt,this._update(e),null!==this._onUpdate&&this._onUpdate(this._time,e)},Ticker.prototype.convertToTicks=function(t){return t/this.tupt},Ticker.prototype.convertToTimeUnits=function(t){return t*this.tupt}; -},{"./Tweener":19}],14:[function(require,module,exports){ -function Timeline(){return this instanceof Timeline==!1?new Timeline:void BriefPlayer.call(this)}var BriefPlayer=require("./BriefPlayer");Timeline.prototype=Object.create(BriefPlayer.prototype),Timeline.prototype.constructor=Timeline,module.exports=Timeline,Timeline.prototype.add=function(e,i){(null===i||void 0===i)&&(i=0),e._setStartTime(i),this._add(e);var t=e._getEndTime();return t>this._duration&&this._setDuration(t),this}; +},{"./Tweener":22}],16:[function(require,module,exports){ +function Timeline(){return this instanceof Timeline==!1?new Timeline:void BriefPlayer.call(this)}var BriefPlayer=require("./BriefPlayer");Timeline.prototype=Object.create(BriefPlayer.prototype),Timeline.prototype.constructor=Timeline,module.exports=Timeline,Timeline.prototype.add=function(e,i){null!==i&&void 0!==i||(i=0),e._setStartTime(i),this._add(e);var t=e._getEndTime();return t>this._duration&&this._setDuration(t),this}; -},{"./BriefPlayer":4}],15:[function(require,module,exports){ +},{"./BriefPlayer":4}],17:[function(require,module,exports){ function Timer(e){return this instanceof Timer==!1?new Timer(e):(Tweener.call(this),void(this._speed=e/1e3||1))}var Tweener=require("./Tweener");Timer.prototype=Object.create(Tweener.prototype),Timer.prototype.constructor=Timer,module.exports=Timer,Object.defineProperty(Timer.prototype,"tups",{get:function(){return 1e3*this._speed},set:function(e){this.speed=e/1e3}}),Timer.prototype.convertToSeconds=function(e){return e/(1e3*this._speed)},Timer.prototype.convertToTimeUnits=function(e){return e*this._speed*1e3}; -},{"./Tweener":19}],16:[function(require,module,exports){ +},{"./Tweener":22}],18:[function(require,module,exports){ function update(t,i){var s=this.prop;t[s]=this.from[s]*(1-i)+this.to[s]*i}function updateP(t,i){for(var s=this.props,a=0;at?2*t*t:2*(2*t-t*t)-1},exports.cubicIn=function(t){return t*t*t},exports.cubicOut=function(t){return 3*t-3*t*t+t*t*t},exports.cubicInOut=function(t){return.5>t?4*t*t*t:4*(3*t-3*t*t+t*t*t)-3},exports.quarticIn=function(t){return t*t*t*t},exports.quarticOut=function(t){var n=t*t;return 4*t-6*n+4*n*t-n*n},exports.quarticInOut=function(t){if(.5>t)return 8*t*t*t*t;var n=t*t;return 8*(4*t-6*n+4*n*t-n*n)-7},exports.polyIn=function(t,n){return Math.pow(t,n)},exports.polyOut=function(t,n){return 1-Math.pow(1-t,n)},exports.polyInOut=function(t,n){return.5>t?Math.pow(2*t,n)/2:(2-Math.pow(2*(1-t),n))/2},exports.sineIn=function(t){return 1-Math.cos(PI_OVER_TWO*t)},exports.sineOut=function(t){return Math.sin(PI_OVER_TWO*t)},exports.sineInOut=function(t){return.5>t?(1-Math.cos(PI*t))/2:(1+Math.sin(PI*(t-.5)))/2},exports.expIn=function(t,n){return(1-Math.pow(EXP,n*t))/(1-Math.pow(EXP,n))},exports.expOut=function(t,n){return(1-Math.pow(EXP,-n*t))/(1-Math.pow(EXP,-n))},exports.expInOut=function(t,n){return.5>t?(1-Math.pow(EXP,2*n*t))/(1-Math.pow(EXP,n))/2:.5+(1-Math.pow(EXP,n-2*n*t))/(1-Math.pow(EXP,-n))/2},exports.circIn=function(t){return 1-Math.sqrt(1-Math.pow(t,2))},exports.circOut=function(t){return Math.sqrt(1-Math.pow(1-t,2))},exports.circInOut=function(t){return.5>t?(1-Math.sqrt(1-4*t*t))/2:(1+Math.sqrt(-3+8*t-4*t*t))/2},exports.elasticIn=function(t,n){if(0===t)return 0;n/=n+1;var r=(1+n)*Math.log(t)/Math.log(n);return Math.cos(r)*Math.pow(n,r)},exports.elasticOut=function(t,n){if(1===t)return 1;n/=n+1;var r=(1+n)*Math.log(1-t)/Math.log(n);return 1-Math.cos(r)*Math.pow(n,r)},exports.elasticInOut=function(t,n){var r;return.5>t?0===t?0:(n/=n+1,r=(1+n)*Math.log(2*t)/Math.log(n),.5*Math.cos(r)*Math.pow(n,r)):1===t?1:(n/=n+1,r=(1+n)*Math.log(2-2*t)/Math.log(n),.5+.5*(1-Math.cos(r)*Math.pow(n,r)))},exports.bounceIn=function(t,n){if(0===t)return 0;n/=n+1;var r=(1+n)*Math.log(t)/Math.log(n);return Math.abs(Math.cos(r)*Math.pow(n,r))},exports.bounceOut=function(t,n){if(1===t)return 1;n/=n+1;var r=(1+n)*Math.log(1-t)/Math.log(n);return 1-Math.abs(Math.cos(r)*Math.pow(n,r))},exports.bounceInOut=function(t,n){var r;return.5>t?0===t?0:(n/=n+1,r=(1+n)*Math.log(2*t)/Math.log(n),Math.abs(.5*Math.cos(r)*Math.pow(n,r))):1===t?1:(n/=n+1,r=(1+n)*Math.log(2-2*t)/Math.log(n),.5+.5*(1-Math.abs(Math.cos(r)*Math.pow(n,r))))},exports.backIn=function(t,n){return t*t*((n+1)*t-n)},exports.backOut=function(t,n){return t-=1,t*t*((n+1)*t+n)+1},exports.backInOut=function(t,n){return.5>t?(t*=2,.5*(t*t*((n+1)*t-n))):(t=2*t-2,.5*(t*t*((n+1)*t+n))+1)}; -},{}],21:[function(require,module,exports){ -var TINA=require("./TINA.js");TINA.Delay=require("./Delay"),TINA.BriefExtension=require("./BriefExtension"),TINA.BriefPlayable=require("./BriefPlayable"),TINA.BriefPlayer=require("./BriefPlayer"),TINA.easing=require("./easing"),TINA.interpolation=require("./interpolation"),TINA.NestedTween=require("./NestedTween"),TINA.PixiTween=require("./NestedTween"),TINA.Playable=require("./Playable"),TINA.Player=require("./Player"),TINA.Recorder=require("./Recorder"),TINA.Sequence=require("./Sequence"),TINA.Ticker=require("./Ticker"),TINA.Timeline=require("./Timeline"),TINA.Timer=require("./Timer"),TINA.Tween=require("./Tween"),TINA.Tweener=require("./Tweener"),module.exports=TINA; -},{"./BriefExtension":2,"./BriefPlayable":3,"./BriefPlayer":4,"./Delay":5,"./NestedTween":7,"./Playable":8,"./Player":9,"./Recorder":10,"./Sequence":11,"./TINA.js":12,"./Ticker":13,"./Timeline":14,"./Timer":15,"./Tween":18,"./Tweener":19,"./easing":20,"./interpolation":23}],22:[function(require,module,exports){ +},{}],24:[function(require,module,exports){ +var TINA=require("./TINA.js");TINA.CSSTween=require("./CSSTween"),TINA.Delay=require("./Delay"),TINA.BriefExtension=require("./BriefExtension"),TINA.BriefPlayable=require("./BriefPlayable"),TINA.BriefPlayer=require("./BriefPlayer"),TINA.easing=require("./easing"),TINA.interpolation=require("./interpolation"),TINA.NestedTween=require("./NestedTween"),TINA.PixiTween=require("./NestedTween"),TINA.Playable=require("./Playable"),TINA.Player=require("./Player"),TINA.Recorder=require("./Recorder"),TINA.Sequence=require("./Sequence"),TINA.Ticker=require("./Ticker"),TINA.Timeline=require("./Timeline"),TINA.Timer=require("./Timer"),TINA.Tween=require("./Tween"),TINA.Tweener=require("./Tweener"),module.exports=TINA; +},{"./BriefExtension":2,"./BriefPlayable":3,"./BriefPlayer":4,"./CSSTween":6,"./Delay":7,"./NestedTween":9,"./Playable":10,"./Player":11,"./Recorder":12,"./Sequence":13,"./TINA.js":14,"./Ticker":15,"./Timeline":16,"./Timer":17,"./Tween":21,"./Tweener":22,"./easing":23,"./interpolation":26}],25:[function(require,module,exports){ module.exports=function(o,t){for(var e=Object.keys(t.prototype),p=0;pa?t:a>=e-1?o:n[a-1]},exports.colorRGB=function(r,t,o){return{r:t.r*(1-r)+o.r*r,g:t.g*(1-r)+o.g*r,b:t.b*(1-r)+o.b*r}},exports.colorRGBA=function(r,t,o){return{r:t.r*(1-r)+o.r*r,g:t.g*(1-r)+o.g*r,b:t.b*(1-r)+o.b*r,a:t.a*(1-r)+o.a*r}},exports.colorRGBToHexa=function(r,t,o){var n=Math.round(t.r*(1-r)+o.r*r),e=Math.round(t.g*(1-r)+o.g*r),a=Math.round(t.b*(1-r)+o.b*r);return"#"+n.toString(16)+e.toString(16)+a.toString(16)},exports.colorRGBToString=function(r,t,o){var n=Math.round(t.r*(1-r)+o.r*r),e=Math.round(t.g*(1-r)+o.g*r),a=Math.round(t.b*(1-r)+o.b*r);return"rgb("+n.toString(16)+","+e.toString(16)+","+a.toString(16)+")"},exports.colorRGBAToString=function(r,t,o){var n=Math.round(t.r*(1-r)+o.r*r),e=Math.round(t.g*(1-r)+o.g*r),a=Math.round(t.b*(1-r)+o.b*r),u=Math.round(t.a*(1-r)+o.a*r);return"rgba("+n.toString(16)+","+e.toString(16)+","+a.toString(16)+","+u+")"},exports.string=function(r,t,o){for(var n=t.length,e=o.length,a="",u=0;e>u;u+=1){var i=o.charCodeAt(u),f=u>=n?97>i?65:97:t.charCodeAt(u),c=Math.round(f*(1-r)+i*r);a+=String.fromCharCode(c)}return a},exports.bezierQuadratic=function(r,t,o,n){var e=1-r;return e*e*t+r*(2*e*n[0]+r*o)},exports.bezierCubic=function(r,t,o,n){var e=1-r;return e*e*e*t+r*(3*e*e*n[0]+r*(3*e*n[1]+r*o))},exports.bezierQuartic=function(r,t,o,n){var e=1-r,a=2*e;return a*a*t+r*(4*e*a*n[0]+r*(6*a*n[1]+r*(4*e*n[2]+r*o)))},exports.bezierQuintic=function(r,t,o,n){var e=1-r,a=2*e;return a*a*e*t+r*(5*a*a*n[0]+r*(10*e*a*n[1]+r*(10*a*n[2]+r*(5*e*n[3]+r*o))))},exports.bezier=function(r,t,o,n){var e=n.length,a=1-r,u=o,i=e;for(k=1;kg;g-=1)e=h*Math.pow(i,g),a=n[u-g],f=f*r+e*a[0],c=c*r+e*a[1],h*=(u-g)/(g+1);return e=Math.pow(i,u),[f*r+t[0]*e,c*r+t[1]*e]},exports.bezier3d=function(r,t,o,n){for(var e,a,u=n.length,i=1-r,f=o[0],c=o[1],h=o[2],g=u,x=1;u>x;x-=1)e=g*Math.pow(i,x),a=n[u-x],f=f*r+e*a[0],c=c*r+e*a[1],h=h*r+e*a[2],g*=(u-x)/(x+1);return e=Math.pow(i,u),[f*r+t[0]*e,c*r+t[1]*e,h*r+t[2]*e]},exports.bezierKd=function(r,t,o,n){for(var e=n.length,a=1-r,u=t.length,i=[],f=0;u>f;f+=1)i[f]=o[f];for(var c,h,g=e,x=1;e>x;x-=1){for(c=g*Math.pow(a,x),h=n[e-x],f=0;u>f;f+=1)i[f]=i[f]*r+c*h[f];g*=(e-x)/(x+1)}for(c=Math.pow(a,e),f=0;u>f;f+=1)i[f]=i[f]*r+t[f]*c;return i},exports.catmullRom=function(r,t,o,n){if(1===r)return n;var e=t.length,a=o.length+1;r*=a;var u=Math.floor(r);r-=u;for(var i=r*r,f=r*i,c=-.5*f+1*i-.5*r,h=1.5*f-2.5*i+1,g=-1.5*f+2*i+.5*r,x=.5*f-.5*i,p=u-2,v=u-1,s=u,l=u+1,M=0>p?t:o[p],b=0>v?t:o[v],d=a-2>l?o[s]:n,S=a-2>l?o[l]:n,y=[],z=0;e>z;z+=1)y[z]=M[z]*c+b[z]*h+d[z]*g+S[z]*x;return y},exports.noise=function(){var r=[182,235,131,26,88,132,100,117,202,176,10,19,83,243,75,52,252,194,32,30,72,15,124,53,236,183,121,103,175,39,253,120,166,33,237,141,99,180,18,143,69,136,173,21,210,189,16,142,190,130,109,186,104,80,62,51,165,25,122,119,42,219,146,61,149,177,54,158,27,170,60,201,159,193,203,58,154,222,78,138,220,41,98,14,156,31,29,246,81,181,40,161,192,227,35,241,135,150,89,68,134,114,230,123,187,179,67,217,71,218,7,148,228,251,93,8,140,125,73,37,82,28,112,24,174,118,232,137,191,133,147,245,6,172,95,113,185,205,254,116,55,198,57,152,128,233,74,225,34,223,79,111,215,85,200,9,242,12,167,44,20,110,107,126,86,231,234,76,207,102,214,238,221,145,213,64,197,38,168,157,87,92,255,212,49,196,240,90,63,0,77,94,1,108,91,17,224,188,153,250,249,199,127,59,46,184,36,43,209,206,248,4,56,47,226,13,144,22,11,247,70,244,48,97,151,195,96,101,45,66,239,178,171,160,84,65,23,3,211,162,163,50,105,129,155,169,115,5,106,2,208,204,139,229,164,216,182],t=[-1,1];return function(o,n,e,a){for(var u=2,i=a.per||1,f=a.frq||2,c=a.oct||4,h=a.off||0,g=0,x=a.x+h,p=0;c>p;p+=1){var v=255&(x|x),s=x-(x|x),l=1-s;g+=u*(l*l*s*(3-2*l)*t[1&r[v]]-s*s*l*(3-2*s)*t[1&r[v+1]]),x*=(x-h)*f+h,u*=i}var M=1===i?1/c:.5*(1-i)/(1-Math.pow(i,c));return o+=g*M,n*(1-o)+e*o}}(),exports.simplex2d=function(){function r(r,t,o){return r[0]*t+r[1]*o}var t=[182,235,131,26,88,132,100,117,202,176,10,19,83,243,75,52,252,194,32,30,72,15,124,53,236,183,121,103,175,39,253,120,166,33,237,141,99,180,18,143,69,136,173,21,210,189,16,142,190,130,109,186,104,80,62,51,165,25,122,119,42,219,146,61,149,177,54,158,27,170,60,201,159,193,203,58,154,222,78,138,220,41,98,14,156,31,29,246,81,181,40,161,192,227,35,241,135,150,89,68,134,114,230,123,187,179,67,217,71,218,7,148,228,251,93,8,140,125,73,37,82,28,112,24,174,118,232,137,191,133,147,245,6,172,95,113,185,205,254,116,55,198,57,152,128,233,74,225,34,223,79,111,215,85,200,9,242,12,167,44,20,110,107,126,86,231,234,76,207,102,214,238,221,145,213,64,197,38,168,157,87,92,255,212,49,196,240,90,63,0,77,94,1,108,91,17,224,188,153,250,249,199,127,59,46,184,36,43,209,206,248,4,56,47,226,13,144,22,11,247,70,244,48,97,151,195,96,101,45,66,239,178,171,160,84,65,23,3,211,162,163,50,105,129,155,169,115,5,106,2,208,204,139,229,164,216,182,235,131,26,88,132,100,117,202,176,10,19,83,243,75,52,252,194,32,30,72,15,124,53,236,183,121,103,175,39,253,120,166,33,237,141,99,180,18,143,69,136,173,21,210,189,16,142,190,130,109,186,104,80,62,51,165,25,122,119,42,219,146,61,149,177,54,158,27,170,60,201,159,193,203,58,154,222,78,138,220,41,98,14,156,31,29,246,81,181,40,161,192,227,35,241,135,150,89,68,134,114,230,123,187,179,67,217,71,218,7,148,228,251,93,8,140,125,73,37,82,28,112,24,174,118,232,137,191,133,147,245,6,172,95,113,185,205,254,116,55,198,57,152,128,233,74,225,34,223,79,111,215,85,200,9,242,12,167,44,20,110,107,126,86,231,234,76,207,102,214,238,221,145,213,64,197,38,168,157,87,92,255,212,49,196,240,90,63,0,77,94,1,108,91,17,224,188,153,250,249,199,127,59,46,184,36,43,209,206,248,4,56,47,226,13,144,22,11,247,70,244,48,97,151,195,96,101,45,66,239,178,171,160,84,65,23,3,211,162,163,50,105,129,155,169,115,5,106,2,208,204,139,229,164,216],o=[[1,1],[-1,1],[1,-1],[-1,-1],[1,0],[-1,0],[1,0],[-1,0],[0,1],[0,-1],[0,1],[0,-1],[1,1],[-1,1],[1,-1],[-1,-1]];return function(n,e,a,u){for(var i=2,f=u.per||1,c=u.frq||2,h=u.oct||4,g=u.off||{x:0,y:0},x=x,p=u.x+g.x,v=u.y+g.y,s=0;h>s;s+=1){var l,M,b,d=.5*(Math.sqrt(3)-1),S=(p+v)*d,y=Math.floor(p+S),z=Math.floor(v+S),w=(3-Math.sqrt(3))/6,k=(y+z)*w,R=y-k,B=z-k;R=p-R,B=v-B;var C,G;R>B?(C=1,G=0):(C=0,G=1);var m=R-C+w,q=B-G+w,A=R-1+2*w,Q=B-1+2*w,T=255&y,X=255&z,Y=.5-R*R-B*B,H=.5-m*m-q*q,K=.5-A*A-Q*Q;if(0>Y)l=0;else{var Z=15&t[T+t[X]];Y*=Y,l=Y*Y*r(o[Z],R,B)}if(0>H)M=0;else{var j=15&t[T+C+t[X+G]];H*=H,M=H*H*r(o[j],m,q)}if(0>K)b=0;else{var D=15&t[T+1+t[X+1]];K*=K,b=K*K*r(o[D],A,Q)}x+=70*i*(l+M+b),p*=(p-g.x)*c+g.x,v*=(v-g.y)*c+g.y,i*=f}var E=1===f?1/h:.5*(1-f)/(1-Math.pow(f,h));return n+=x*E,e*(1-n)+a*n}}(); -},{}]},{},[21]); +},{}]},{},[24]); diff --git a/examples/css/index.html b/examples/css/index.html new file mode 100644 index 0000000..9a3a775 --- /dev/null +++ b/examples/css/index.html @@ -0,0 +1,29 @@ + + + + Tina - CSS + + + + + + tina - CSS +
+
+
+ + + --> + + jsfiddle + + diff --git a/examples/css/index.js b/examples/css/index.js new file mode 100644 index 0000000..3e3706b --- /dev/null +++ b/examples/css/index.js @@ -0,0 +1,32 @@ + +var demoDiv = document.getElementById('demodiv'); + +//▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ + +TINA.onUpdate(function update(t, dt) { + // At this point, all my tweens are up to date for the current iteration +}); + +//▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ + +var duration = 2000; +var bouncing = 4; + +// NOTE: The available CSS properties options are currently: +// top, bottom, left, right, width, height and opacity +var csstween = new TINA.CSSTween(demodiv, ['top', 'width', 'opacity', 'height']) +.from({ + top: 50, + width: 100, + height: 100, + opacity: 1 +}) +.to({ + top: 200, + width: 200, + height: 200, + opacity: 0 +}, 2000) +.iterations(Infinity) +.pingpong(true) +.start(); diff --git a/examples/styles.css b/examples/styles.css index 63d12b7..f27f3d6 100644 --- a/examples/styles.css +++ b/examples/styles.css @@ -4,6 +4,7 @@ body { font-family: verdana; } +.democontainer, canvas { margin: 20px auto; border-radius: 5px; @@ -11,6 +12,12 @@ canvas { display: block; } +.democontainer { + position: relative; + width: 400px; + height: 400px; +} + a { color: #AAA; } @@ -40,4 +47,4 @@ a:active { .hidden { display: none; -} \ No newline at end of file +} diff --git a/src/AbstractTween.js b/src/AbstractTween.js index c4ffa84..c87370a 100644 --- a/src/AbstractTween.js +++ b/src/AbstractTween.js @@ -1,8 +1,8 @@ -var Transition = require('./Transition'); -var TransitionRelative = require('./TransitionRelative'); - -var easingFunctions = require('./easing'); -var interpolationFunctions = require('./interpolation'); +var Transition = require('./Transition'); +var TransitionCSS = require('./TransitionCSS'); +var TransitionRelative = require('./TransitionRelative'); +var easingFunctions = require('./easing'); +var interpolationFunctions = require('./interpolation'); // Temporisation, used for waiting @@ -45,6 +45,13 @@ function AbstractTween(object, properties) { } } + // Determine if we are are tweening a CSS object + // The undefined check is to avoid a crash when running Tina in + // environments where the DOM is not available, such as in node. + if (typeof CSSStyleDeclaration !== 'undefined') { + this._css = (object instanceof CSSStyleDeclaration) ? true : false; + } + // Properties to tween this._properties = properties; @@ -155,7 +162,16 @@ AbstractTween.prototype.to = function (toObject, duration, easing, easingParam, // Getting previous transition ending as the beginning for the new transition var fromObject = this._getLastTransitionEnding(); - var TransitionConstructor = (this._relative === true) ? TransitionRelative : Transition; + // Determine the appropriate transition constructor for the given object + var TransitionConstructor = null; + if (this._relative === true) { + TransitionConstructor = TransitionRelative; + } else if (this._css === true) { + TransitionConstructor = TransitionCSS; + } else { + TransitionConstructor = Transition; + } + var transition = new TransitionConstructor( this._properties, fromObject, @@ -220,4 +236,4 @@ AbstractTween.prototype._validate = function () { } return true; -}; \ No newline at end of file +}; diff --git a/src/CSSMap.js b/src/CSSMap.js new file mode 100644 index 0000000..cb886e2 --- /dev/null +++ b/src/CSSMap.js @@ -0,0 +1,27 @@ +/** + * + * Maps the given properties to a unit type + * + * Currently only supports basic CSS methods - in order to support more advance CSS3 properties, such as + * transform, we will need to modify the way the properties array is handled and moved through the system. + * In the case of CSS methods such as "transform: rotate(Xdeg)" - the mapping will need to be more advanced, + * possibly adding a prefix / suffix mapping. + * + * @param {array} properties - Properties of the object to tween + * @returns {array} - The suffix mapped to the property name + * + */ +module.exports = function (properties) { + + var cssMap = { height: 'px', width: 'px', top: 'px', left: 'px', bottom: 'px', right: 'px', opacity: '' }; + var mapping = {}; + + for (var i = 0; i < properties.length; i++) { + if (properties[i] in cssMap) { + var property = properties[i]; + mapping[property] = cssMap[property]; + } + } + + return mapping; +}; diff --git a/src/CSSTween.js b/src/CSSTween.js index db4a41e..accfd49 100644 --- a/src/CSSTween.js +++ b/src/CSSTween.js @@ -1,5 +1,4 @@ -var Tween = require('./Tween'); - +var NestedTween = require('./NestedTween'); /** * * @classdesc @@ -17,10 +16,10 @@ function CSSTween(object, properties) { var tweenedObject = (typeof object === 'string') ? document.querySelector(object) : object; - // TODO: change inheritance to NestedTween for support of css transform properties - // and add an internal method for replacing unprefixed properties by prefixed properties when necessary - Tween.call(this, tweenedObject.style, properties); + // TODO: Add an internal method for replacing unprefixed properties by prefixed properties when necessary + NestedTween.call(this, tweenedObject.style, properties); } -CSSTween.prototype = Object.create(Tween.prototype); + +CSSTween.prototype = Object.create(NestedTween.prototype); CSSTween.prototype.constructor = CSSTween; -module.exports = CSSTween; \ No newline at end of file +module.exports = CSSTween; diff --git a/src/TransitionCSS.js b/src/TransitionCSS.js new file mode 100644 index 0000000..574553d --- /dev/null +++ b/src/TransitionCSS.js @@ -0,0 +1,135 @@ +// Provides transitions for CSS style objects +var CSSMap = require('./CSSMap'); + +// One property +function update(object, t) { + var p = this.prop; + object[p] = (this.from[p] * (1 - t) + this.to[p] * t) + this.cssMap[p]; +} + +// Several Properties +function updateP(object, t) { + var q = this.props; + for (var i = 0; i < this.props.length; i += 1) { + var p = q[i]; + object[p] = (this.from[p] * (1 - t) + this.to[p] * t) + this.cssMap[p]; + } +} + +// Interpolation +function updateI(object, t) { + var p = this.prop; + object[p] = this.interps[p](t, this.from[p], this.to[p], this.interpParams[p]) + this.cssMap[p]; +} + +// Interpolation +// Several Properties +function updatePI(object, t) { + var q = this.props; + for (var i = 0; i < q.length; i += 1) { + var p = q[i]; + object[p] = this.interps[p](t, this.from[p], this.to[p], this.interpParams[p]) + this.cssMap[p]; + } +} + +// Easing +function updateE(object, t) { + t = this.easing(t, this.easingParam); + var p = this.prop; + object[p] = (this.from[p] * (1 - t) + this.to[p] * t) + this.cssMap[p]; +} + +// Easing +// Several Properties +function updatePE(object, t, interpFunc) { + var q = this.props; + t = this.easing(t, this.easingParam); + for (var i = 0; i < q.length; i += 1) { + var p = q[i]; + object[p] = (this.from[p] * (1 - t) + this.to[p] * t) + this.cssMap[p]; + } +} + +// Easing +// Interpolation +function updateIE(object, t, interpFunc) { + var p = this.prop; + t = this.easing(t, this.easingParam); + object[p] = this.interps[p](t, this.from[p], this.to[p], this.interpParams[p]) + this.cssMap[p]; +} + +// Easing +// Interpolation +// Several Properties +function updatePIE(object, t, interpFunc) { + var q = this.props; + t = this.easing(t, this.easingParam); + for (var i = 0; i < q.length; i += 1) { + var p = q[i]; + object[p] = this.interps[p](t, this.from[p], this.to[p], this.interpParams[p]) + this.cssMap[p]; + } +} + + +var updateMethods = [ + [ + [update, updateP], + [updateI, updatePI] + ], [ + [updateE, updatePE], + [updateIE, updatePIE] + ] +]; + +function TransitionCSS(properties, from, to, start, duration, easing, + easingParam, interpolations, interpolationParams) { + + this.start = start; + this.end = start + duration; + this.duration = duration; + this.from = from; + this.to = to; + this.cssMap = CSSMap(properties); + + // Easing flag - Whether an easing function is used + // 0 => Using linear easing + // 1 => Using custom easing + var easingFlag; + if (easing) { + easingFlag = 1; + this.easing = easing; + this.easingParam = easingParam; + } else { + easingFlag = 0; + } + + // Interpolation flag - Whether an interpolation function is used + // 0 => No Interpolation + // 1 => At least one interpolation + var interpFlag; + if (interpolations === null) { + interpFlag = 0; + } else { + interpFlag = 1; + this.interps = interpolations; + this.interpParams = interpolationParams || {}; + } + + // Property flag - Whether the transition has several properties + // 0 => Only one property + // 1 => Several properties + var propsFlag; + if (properties.length === 1) { + propsFlag = 0; + this.prop = properties[0]; // string + this.props = null; + } else { + propsFlag = 1; + this.prop = null; + this.props = properties; // array + } + + this.update = updateMethods[easingFlag][interpFlag][propsFlag]; +} + +module.exports = TransitionCSS; diff --git a/src/index.js b/src/index.js index d00e31e..ab04630 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,6 @@ var TINA = require('./TINA.js'); -// TINA.CSSTween = require('./CSSTween'); +TINA.CSSTween = require('./CSSTween'); TINA.Delay = require('./Delay'); TINA.BriefExtension = require('./BriefExtension'); TINA.BriefPlayable = require('./BriefPlayable');