Comparing version 0.3.3 to 0.3.4
@@ -5,3 +5,3 @@ (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<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
},{"./Transition":15,"./TransitionRelative":16,"./easing":19,"./interpolation":22}],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.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._startTime<t&&t<this._startTime+this.getDuration():this._speed<0?this._startTime+this.getDuration()<t&&t<this._startTime:!0},BriefExtension.prototype.goToEnd=function(){return this.goTo(this.getDuration(),this._iterations-1),this},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))},BriefExtension.prototype._moveTo=function(t,i,e){if(i*=this._speed,void 0===e){if(0!==i)if(1===this._iterations)this._time=(t-this._startTime)*this._speed,i>0?this._time>=this._duration&&(e=this._time-this._duration,i-=e,this._time=this._duration):0>i&&this._time<=0&&(e=this._time,i-=e,this._time=0);else{t=(t-this._startTime)*this._speed;var s=t/this._duration;i>0?s<this._iterations?this._time=t%this._duration:(e=(s-this._iterations)*this._duration,i-=e,this._time=this._duration*(1-(Math.ceil(this._iterations)-this._iterations))):0>i&&(s>0?this._time=t%this._duration:(e=s*this._duration,i-=e,this._time=0)),this._pingpong===!0&&(Math.ceil(this._iterations)===this._iterations?void 0===e?0===(1&Math.ceil(s))&&(this._time=this._duration-this._time):1===(1&Math.ceil(s))&&(this._time=this._duration-this._time):0===(1&Math.ceil(s))&&(this._time=this._duration-this._time))}}else i>0?(e=Math.max((t-this._startTime)*this._speed-this._duration*this.iterations,0),this._time=this._duration):(e=Math.min((t-this._startTime)*this._speed,0),this._time=0),i-=e;this._update(i,e),null!==this._onUpdate&&this._onUpdate(this._time,i),void 0!==e&&this._complete(e)}; | ||
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._startTime<t&&t<this._startTime+this.getDuration():this._speed<0?this._startTime+this.getDuration()<t&&t<this._startTime:!0},BriefExtension.prototype.goToEnd=function(){return this.goTo(this.getDuration(),this._iterations-1),this},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))},BriefExtension.prototype._moveTo=function(t,i,e){if(i*=this._speed,void 0===e){if(0!==i)if(1===this._iterations)this._time=(t-this._startTime)*this._speed,i>0?this._time>=this._duration&&(e=this._time-this._duration,i-=e,this._time=this._duration):0>i&&this._time<=0&&(e=this._time,i-=e,this._time=0);else{t=(t-this._startTime)*this._speed;var s=t/this._duration;i>0?s<this._iterations?this._time=t%this._duration:(e=(s-this._iterations)*this._duration,i-=e,this._time=this._duration*(1-(Math.ceil(this._iterations)-this._iterations))):0>i&&(s>0?this._time=t%this._duration:(e=s*this._duration,i-=e,this._time=0)),this._pingpong===!0&&(Math.ceil(this._iterations)===this._iterations?void 0===e?0===(1&Math.ceil(s))&&(this._time=this._duration-this._time):1===(1&Math.ceil(s))&&(this._time=this._duration-this._time):0===(1&Math.ceil(s))&&(this._time=this._duration-this._time))}}else i>0?(e=Math.max((t-this._startTime)*this._speed-this._duration*this.iterations,0),this._time=this._duration):(e=Math.min((t-this._startTime)*this._speed,0),this._time=0),i-=e;this._update(i,e),null!==this._onUpdate&&this._onUpdate(this._time,i),void 0!==e&&this._complete(e)}; | ||
@@ -12,3 +12,3 @@ },{}],3:[function(require,module,exports){ | ||
},{"./BriefExtension":2,"./Playable":8,"./inherit":21}],4:[function(require,module,exports){ | ||
function BriefPlayer(){Player.call(this),BriefExtension.call(this)}var inherit=require("./inherit"),Player=require("./Player"),BriefExtension=require("./BriefExtension");BriefPlayer.prototype=Object.create(Player.prototype),BriefPlayer.prototype.constructor=BriefPlayer,inherit(BriefPlayer,BriefExtension),module.exports=BriefPlayer,BriefPlayer.prototype._onAllPlayablesRemoved=function(){this._duration=0},BriefPlayer.prototype._updateDuration=function(){var e,t,r,i=0;for(e=this._activePlayables.first;null!==e;e=e.next)t=e.object,r=t._getEndTime()-this._duration,r>i&&(i=r);for(e=this._inactivePlayables.first;null!==e;e=e.next)t=e.object,r=t._getEndTime()-this._duration,r>i&&(i=r);i>0&&this._extendDuration(i)},BriefPlayer.prototype._onPlayableRemoved=function(){this._updateDuration()},BriefPlayer.prototype._onPlayableChanged=function(e){this._warn("[BriefPlayer._onPlayableChanged] Changing a playable's property after attaching it to a player may have unwanted side effects","playable:",e,"player:",this)}; | ||
function BriefPlayer(){Player.call(this),BriefExtension.call(this)}var inherit=require("./inherit"),Player=require("./Player"),BriefExtension=require("./BriefExtension");BriefPlayer.prototype=Object.create(Player.prototype),BriefPlayer.prototype.constructor=BriefPlayer,inherit(BriefPlayer,BriefExtension),module.exports=BriefPlayer,BriefPlayer.prototype._onAllPlayablesRemoved=function(){this._duration=0},BriefPlayer.prototype._updateDuration=function(){var e,r,t,i=0;for(e=this._activePlayables.first;null!==e;e=e.next)r=e.object,t=r._getStartTime()+r.getDuration(),t>i&&(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; | ||
@@ -19,3 +19,3 @@ },{"./BriefExtension":2,"./Player":9,"./inherit":21}],5:[function(require,module,exports){ | ||
},{"./BriefPlayable":3}],6:[function(require,module,exports){ | ||
function ListNode(t,e,i,o){this.object=t,this.previous=e,this.next=i,this.container=o}function DoublyList(){this.first=null,this.last=null,this.length=0}module.exports=DoublyList,DoublyList.prototype.addFront=function(t){var e=new ListNode(t,null,this.first,this);return null===this.first?(this.first=e,this.last=e):(this.first.previous=e,this.first=e),this.length+=1,e},DoublyList.prototype.add=DoublyList.prototype.addFront,DoublyList.prototype.addBack=function(t){var e=new ListNode(t,this.last,null,this);return null===this.first?(this.first=e,this.last=e):(this.last.next=e,this.last=e),this.length+=1,e},DoublyList.prototype.popFront=function(t){var e=this.first.object;return this.removeByReference(this.first),e},DoublyList.prototype.pop=DoublyList.prototype.popFront,DoublyList.prototype.popBack=function(t){var e=this.last.object;return this.removeByReference(this.last),e},DoublyList.prototype.addBefore=function(t,e){var i=new ListNode(e,t,t.next,this);return null!==t.next&&(t.next.previous=i),t.next=i,this.first===t&&(this.first=i),this.length+=1,i},DoublyList.prototype.addAfter=function(t,e){var i=new ListNode(e,t.previous,t,this);return null!==t.previous&&(t.previous.next=i),t.previous=i,this.last===t&&(this.last=i),this.length+=1,i},DoublyList.prototype.removeByReference=function(t){return t.container!==this?(console.warn("[DoublyList.removeByReference] Trying to remove a node that does not belong to the list"),t):(null===t.next?this.last=t.previous:t.next.previous=t.previous,null===t.previous?this.first=t.next:t.previous.next=t.next,t.next=null,t.previous=null,t.container=null,this.length-=1,null)},DoublyList.prototype.remove=function(t){for(var e=this.first;null!==e;e=e.next)if(e.object===t)return this.removeByReference(e),!0;return!1},DoublyList.prototype.clear=function(){for(var t=this.first;null!==t;t=t.next)t.container=null;this.first=null,this.last=null,this.length=0},DoublyList.prototype.forEach=function(t,e){for(var i=this.first;i;i=i.next)t(i.object,e)},DoublyList.prototype.toArray=function(){for(var t=[],e=this.first;null!==e;e=e.next)t.push(e.object);return t}; | ||
function ListNode(t,e,i,o){this.object=t,this.previous=e,this.next=i,this.container=o}function DoublyList(){this.first=null,this.last=null,this.length=0}module.exports=DoublyList,DoublyList.prototype.addFront=function(t){var e=new ListNode(t,null,this.first,this);return null===this.first?(this.first=e,this.last=e):(this.first.previous=e,this.first=e),this.length+=1,e},DoublyList.prototype.add=DoublyList.prototype.addFront,DoublyList.prototype.addBack=function(t){var e=new ListNode(t,this.last,null,this);return null===this.first?(this.first=e,this.last=e):(this.last.next=e,this.last=e),this.length+=1,e},DoublyList.prototype.popFront=function(t){var e=this.first.object;return this.removeByReference(this.first),e},DoublyList.prototype.pop=DoublyList.prototype.popFront,DoublyList.prototype.popBack=function(t){var e=this.last.object;return this.removeByReference(this.last),e},DoublyList.prototype.addBefore=function(t,e){var i=new ListNode(e,t,t.next,this);return null!==t.next&&(t.next.previous=i),t.next=i,this.first===t&&(this.first=i),this.length+=1,i},DoublyList.prototype.addAfter=function(t,e){var i=new ListNode(e,t.previous,t,this);return null!==t.previous&&(t.previous.next=i),t.previous=i,this.last===t&&(this.last=i),this.length+=1,i},DoublyList.prototype.removeByReference=function(t){return t.container!==this?(console.warn("[DoublyList.removeByReference] Trying to remove a node that does not belong to the list"),t):(null===t.next?this.last=t.previous:t.next.previous=t.previous,null===t.previous?this.first=t.next:t.previous.next=t.next,t.next=null,t.previous=null,t.container=null,this.length-=1,null)},DoublyList.prototype.remove=function(t){for(var e=this.first;null!==e;e=e.next)if(e.object===t)return this.removeByReference(e),!0;return!1},DoublyList.prototype.getNode=function(t){for(var e=this.first;null!==e;e=e.next)if(e.object===t)return e;return null},DoublyList.prototype.clear=function(){for(var t=this.first;null!==t;t=t.next)t.container=null;this.first=null,this.last=null,this.length=0},DoublyList.prototype.forEach=function(t,e){for(var i=this.first;i;i=i.next)t(i.object,e)},DoublyList.prototype.toArray=function(){for(var t=[],e=this.first;null!==e;e=e.next)t.push(e.object);return t}; | ||
@@ -26,11 +26,11 @@ },{}],7:[function(require,module,exports){ | ||
},{"./AbstractTween":1,"./BriefPlayable":3}],8:[function(require,module,exports){ | ||
function Playable(){this._player=null,this._handle=null,this._startTime=0,this._time=0,this._speed=1,this._onStart=null,this._onPause=null,this._onResume=null,this._onUpdate=null,this._onStop=null}module.exports=Playable,Object.defineProperty(Playable.prototype,"speed",{get:function(){return this._speed},set: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)}}),Object.defineProperty(Playable.prototype,"time",{get:function(){return this._time},set:function(t){this.goTo(t)}}),Playable.prototype.onStart=function(t){return this._onStart=t,this},Playable.prototype.onUpdate=function(t){return this._onUpdate=t,this},Playable.prototype.onStop=function(t){return this._onStop=t,this},Playable.prototype.onPause=function(t){return this._onPause=t,this},Playable.prototype.onResume=function(t){return this._onResume=t,this},Playable.prototype.tweener=function(t){return null===t||void 0===t?(console.warn("[Playable.tweener] Given tweener is invalid:",t),this):(this._player=t,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.getDuration=function(){return 1/0},Playable.prototype._getEndTime=function(){return this._speed>=0?1/0:this._startTime},Playable.prototype._getStartTime=function(){return this._speed>0?this._startTime:-(1/0)},Playable.prototype._isWithin=function(t){return this._speed>0?this._startTime<t:this._speed<0?t<this._startTime:!0},Playable.prototype.rewind=function(){return this.goTo(0,0),this},Playable.prototype.delay=function(t){return this.start(-t)},Playable.prototype.start=function(t){return null===this._player&&(this._player=TINA._getDefaultTweener()),this._validate()===!1?this:this._player._add(this)===!1?this:((void 0===t||null===t)&&(t=0),this._startTime=this._player._time-t,this)},Playable.prototype._start=function(){null!==this._onStart&&this._onStart()},Playable.prototype.stop=function(){return this._player._inactivate(this)===!1?this:(null!==this._onStop&&this._onStop(),this)},Playable.prototype.resume=function(){return this._player._activate(this)===!1?this:(null!==this._onResume&&this._onResume(),this)},Playable.prototype.pause=function(){return this._player._inactivate(this)===!1?this:(null!==this._onPause&&this._onPause(),this)},Playable.prototype._moveTo=function(t,e){e*=this._speed,this._time=(t-this._startTime)*this._speed,this._update(e),null!==this._onUpdate&&this._onUpdate(this._time,e)},Playable.prototype._update=function(){},Playable.prototype._validate=function(){}; | ||
function Playable(){this._player=null,this._handle=null,this._startTime=0,this._time=0,this._speed=1,this._onStart=null,this._onPause=null,this._onResume=null,this._onUpdate=null,this._onStop=null}module.exports=Playable,Object.defineProperty(Playable.prototype,"speed",{get:function(){return this._speed},set:function(t){this.setSpeed(t)}}),Object.defineProperty(Playable.prototype,"time",{get:function(){return this._time},set:function(t){this.goTo(t)}}),Playable.prototype.onStart=function(t){return this._onStart=t,this},Playable.prototype.onUpdate=function(t){return this._onUpdate=t,this},Playable.prototype.onStop=function(t){return this._onStop=t,this},Playable.prototype.onPause=function(t){return this._onPause=t,this},Playable.prototype.onResume=function(t){return this._onResume=t,this},Playable.prototype.tweener=function(t){return null===t||void 0===t?(console.warn("[Playable.tweener] Given tweener is invalid:",t),this):(this._player=t,this)},Playable.prototype.setSpeed=function(t){return 0>t?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.getDuration=function(){return 1/0},Playable.prototype._getEndTime=function(){return 1/0},Playable.prototype._getStartTime=function(){return this._startTime},Playable.prototype._isWithin=function(t){return this._startTime<t},Playable.prototype.rewind=function(){return this.goTo(0,0),this},Playable.prototype.delay=function(t){return this.start(-t)},Playable.prototype.start=function(t){return null===this._player&&(this._player=TINA._getDefaultTweener()),this._validate()===!1?this:this._player._add(this)===!1?this:((void 0===t||null===t)&&(t=0),this._startTime=this._player._time-t,this)},Playable.prototype._start=function(){null!==this._onStart&&this._onStart()},Playable.prototype.stop=function(){return null===this._player?void console.warn("[Playable.stop] Cannot stop a playable that is not running"):this._player._inactivate(this)===!1?this:(null!==this._onStop&&this._onStop(),this)},Playable.prototype.resume=function(){return this._player._activate(this)===!1?this:(null!==this._onResume&&this._onResume(),this)},Playable.prototype.pause=function(){return this._player._inactivate(this)===!1?this:(null!==this._onPause&&this._onPause(),this)},Playable.prototype._moveTo=function(t,e){e*=this._speed,this._time=(t-this._startTime)*this._speed,this._update(e),null!==this._onUpdate&&this._onUpdate(this._time,e)},Playable.prototype._update=function(){},Playable.prototype._validate=function(){}; | ||
},{}],9:[function(require,module,exports){ | ||
function Player(){Playable.call(this),this._activePlayables=new DoublyList,this._inactivePlayables=new DoublyList,this._playablesToRemove=new DoublyList,this._silent=!1,this._debug=!1}var Playable=require("./Playable"),DoublyList=require("./DoublyList");Player.prototype=Object.create(Playable.prototype),Player.prototype.constructor=Player,module.exports=Player,Player.prototype._add=function(e,a){return null===e._handle?(e._handle=this._inactivePlayables.add(e),e._player=this,!0):e._handle.container===this._playablesToRemove?(e._handle=this._playablesToRemove.removeByReference(e._handle),!0):e._handle.container===this._activePlayables?(this._warn("[Player._add] Playable is already present, and active"),!1):e._handle.container===this._inactivePlayables?(this._warn("[Player._add] Playable is already present, but inactive (could be starting)"),!1):(this._warn("[Player._add] Playable is used elsewhere"),!1)},Player.prototype._remove=function(e){return null===e._handle?(this._warn("[Player._remove] Playable is not being used"),!1):e._handle.container===this._activePlayables?(e._handle=this._playablesToRemove.add(e._handle),!0):e._handle.container===this._inactivePlayables?(e._handle=this._inactivePlayables.removeByReference(e._handle),!0):e._handle.container===this._playablesToRemove?(this._warn("[Player._remove] Playable is already being removed"),!1):(this._warn("[Player._add] Playable is used elsewhere"),!1)},Player.prototype.remove=function(e){return e._handle.container===this._activePlayables&&e.stop(),e._handle.container!==this._playablesToRemove&&this._remove(e),this._onPlayableRemoved(e),this},Player.prototype.removeAll=function(){for(var e=this._activePlayables.first;null!==e;){var a=e.next;e.object.stop(),e=a}return this._handlePlayablesToRemove(),this._onAllPlayablesRemoved(),this},Player.prototype.possess=function(e){return null===e._handle?!1:e._handle.container===this._activePlayables||e._handle.container===this._inactivePlayables},Player.prototype._handlePlayablesToRemove=function(){for(;this._playablesToRemove.length>0;){var e=this._playablesToRemove.pop(),a=e.object;a._handle=this._activePlayables.removeByReference(e),a._player=null}},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,this},Player.prototype.debug=function(e){return this._debug=e,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){this._activePlayables.removeByReference(e._handle),e._handle=this._inactivePlayables.addBack(e)},Player.prototype._updatePlayableList=function(e){this._handlePlayablesToRemove();for(var a=this._inactivePlayables.first;null!==a;){var t=a.object;a=a.next,t._isTimeWithin(this._time)&&(this._activate(t),t._start())}},Player.prototype._update=function(e,a){this._updatePlayableList(e);for(var t=this._activePlayables.first;null!==t;t=t.next)t.object._moveTo(this._time,e,a)},Player.prototype._onPlayableChanged=function(){},Player.prototype._onPlayableRemoved=function(){},Player.prototype._onAllPlayablesRemoved=function(){}; | ||
function Player(){Playable.call(this),this._activePlayables=new DoublyList,this._inactivePlayables=new DoublyList,this._playablesToRemove=new DoublyList,this._silent=!1,this._debug=!1}var Playable=require("./Playable"),DoublyList=require("./DoublyList");Player.prototype=Object.create(Playable.prototype),Player.prototype.constructor=Player,module.exports=Player,Player.prototype._add=function(e){return null===e._handle?(e._handle=this._inactivePlayables.add(e),e._player=this,!0):e._handle.container===this._playablesToRemove?(e._handle=this._playablesToRemove.removeByReference(e._handle),!0):e._handle.container===this._activePlayables?(this._warn("[Player._add] Playable is already present, and active"),!1):e._handle.container===this._inactivePlayables?(this._warn("[Player._add] Playable is already present, but inactive (could be starting)"),!1):(this._warn("[Player._add] Playable is used elsewhere"),!1)},Player.prototype._remove=function(e){return null===e._handle?(this._warn("[Player._remove] Playable is not being used"),!1):e._handle.container===this._activePlayables?(e._handle=this._playablesToRemove.add(e._handle),!0):e._handle.container===this._inactivePlayables?(e._handle=this._inactivePlayables.removeByReference(e._handle),!0):e._handle.container===this._playablesToRemove?(this._warn("[Player._remove] Playable is already being removed"),!1):(this._warn("[Player._add] Playable is used elsewhere"),!1)},Player.prototype.remove=function(e){return e._handle.container===this._activePlayables&&e.stop(),this._remove(e),this._onPlayableRemoved(e),this},Player.prototype.removeAll=function(){for(var e=this._activePlayables.first;null!==e;){var a=e.next;e.object.stop(),e=a}return this._handlePlayablesToRemove(),this},Player.prototype.possess=function(e){return null===e._handle?!1:e._handle.container===this._activePlayables||e._handle.container===this._inactivePlayables},Player.prototype._handlePlayablesToRemove=function(){for(;this._playablesToRemove.length>0;){var e=this._playablesToRemove.pop(),a=e.object;a._handle=this._activePlayables.removeByReference(e),a._player=null}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,this},Player.prototype.debug=function(e){return this._debug=e,this},Player.prototype.stop=function(){if(null===this._player)return void this._warn("[Player.stop] Cannot stop a player that is not running");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){this._activePlayables.removeByReference(e._handle),e._handle=this._inactivePlayables.addBack(e)},Player.prototype._updatePlayableList=function(e){this._handlePlayablesToRemove();for(var a=this._inactivePlayables.first;null!==a;){var t=a.object;a=a.next,t._isTimeWithin(this._time)&&(this._activate(t),t._start())}},Player.prototype._update=function(e,a){this._updatePlayableList(e);for(var t=this._activePlayables.first;null!==t;t=t.next)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){ | ||
function Sequence(){return this instanceof Sequence==!1?new Sequence:void Timeline.call(this)}var Timeline=require("./Timeline"),Delay=require("./Delay");Sequence.prototype=Object.create(Timeline.prototype),Sequence.prototype.constructor=Sequence,module.exports=Sequence,Sequence.prototype.add=function(e){return Timeline.prototype.add.call(this,e,this._duration)},Sequence.prototype.addDelay=function(e){return this.add(new Delay(e))},Sequence.prototype._onPlayableRemoved=function(e){var t,i,r=e._startTime,n=r+e.getDuration();if(r>n){var a=r;r=n,n=a}if(this._time<n){var o=n-this._time;for(t=this._activePlayables.first;null!==t;t=t.next)i=t.object,e._startTime<i._startTime&&(i._startTime-=o);for(t=this._inactivePlayables.first;null!==t;t=t.next)i=t.object,e._startTime<i._startTime&&(i._startTime-=o)}if(this._time>r){var s=this._time-r;this._startTime+=s}this._updateDuration()}; | ||
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,"./Timeline":13}],11:[function(require,module,exports){ | ||
},{"./Delay":5,"./DoublyList":6,"./Timeline":13}],11:[function(require,module,exports){ | ||
(function (global){ | ||
@@ -37,0 +37,0 @@ var 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(t){root.setTimeout(t,1e3/60)}}(),clock=root.performance||Date,TINA={_tweeners:[],_defaultTweener:null,_startTime:0,_time:0,_running:!1,_onStart:null,_onPause:null,_onResume:null,_onUpdate:null,_onStop:null,_pauseOnLostFocus:!1,_pauseOnLostFocusInitialised:!1,onStart:function(t){return this._onStart=t,this},onUpdate:function(t){return this._onUpdate=t,this},onStop:function(t){return this._onStop=t,this},onPause:function(t){return this._onPause=t,this},isRunning:function(){return this._running===!0},update:function(){var t=clock.now()-this._startTime,e=t-this._time;0>e?(e=1,this._startTime-=1,this._time+=1):this._time=t;for(var n=this._tweeners.slice(0),i=0;i<n.length;i+=1)n[i]._moveTo(this._time,e);null!==this._onUpdate&&this._onUpdate(this._time,e)},reset:function(){var t=clock.now(),e=t-this._time;this._startTime+=e,this._time=0},start:function(){if(this._startAutomaticUpdate()!==!1){null!==this._onStart&&this._onStart();for(var t=0;t<this._tweeners.length;t+=1)this._tweeners[t]._start();return this}},stop:function(){if(this._stopAutomaticUpdate()!==!1){for(var t=this._tweeners.slice(0),e=0;e<t.length;e+=1)t[e].stop();return this._tweeners=t,null!==this._onStop&&this._onStop(),this}},_startAutomaticUpdate:function(){function t(){TINA._running===!0&&(TINA.update(),requestAnimFrame(t))}return this._running===!0?(console.warn("[TINA.start] TINA is already running"),!1):(this.reset(),this._running=!0,requestAnimFrame(t),!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 t=0;t<this._tweeners.length;t+=1)this._tweeners[t]._pause();return null!==this._onPause&&this._onPause(),this}},resume:function(){if(this._startAutomaticUpdate()!==!1){null!==this._onResume&&this._onResume();for(var t=0;t<this._tweeners.length;t+=1)this._tweeners[t]._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 t,e;if("undefined"!=typeof document.hidden?(t="hidden",e="visibilitychange"):"undefined"!=typeof document.mozHidden?(t="mozHidden",e="mozvisibilitychange"):"undefined"!=typeof document.msHidden?(t="msHidden",e="msvisibilitychange"):"undefined"!=typeof document.webkitHidden&&(t="webkitHidden",e="webkitvisibilitychange"),"undefined"==typeof document[t])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(e,function(){document[t]&&(n=TINA.isRunning(),n&&TINA._pauseOnLostFocus&&TINA.pause()),document[t]||n&&TINA._pauseOnLostFocus&&TINA.resume()},!1)}},pauseOnLostFocus:function(t){return t===!0&&this._pauseOnLostFocusInitialised===!1&&this._initialisePauseOnLostFocus(),this._pauseOnLostFocus=t,this},setDefaultTweener:function(t){this._defaultTweener=t,this._tweeners.push(this._defaultTweener)},getDefaultTweener:function(){return this._defaultTweener},_add:function(t){this._running===!1&&this.start(),this._tweeners.push(t)},add:function(t){return this._tweeners.push(t),this},_inactivate:function(t){var e=this._tweeners.indexOf(t);-1!==e&&this._tweeners.splice(e,1)},remove:function(t){return this._inactivate(t),this},_getDefaultTweener:function(){if(null===this._defaultTweener){var t=this.Timer;this._defaultTweener=(new t).start()}return this._defaultTweener}};module.exports=global.TINA=TINA; |
{ | ||
"name": "tina", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "Tweening and INterpolations for Animation", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -17,2 +17,25 @@ | ||
BriefExtension.prototype.setSpeed = function (speed) { | ||
if (speed === 0) { | ||
if (this._speed !== 0) { | ||
// Setting timeStart as if new speed was 1 | ||
this._startTime += this._time / this._speed - this._time; | ||
} | ||
} else { | ||
if (this._speed === 0) { | ||
// If current speed is 0, | ||
// it corresponds to a virtual speed of 1 | ||
// when it comes to determing where the starting time is | ||
this._startTime += this._time - this._time / speed; | ||
} else { | ||
this._startTime += this._time / this._speed - this._time / speed; | ||
} | ||
} | ||
this._speed = speed; | ||
if (this._player !== null) { | ||
this._player._onPlayableChanged(this); | ||
} | ||
}; | ||
BriefExtension.prototype.onComplete = function (onComplete) { | ||
@@ -19,0 +42,0 @@ this._onComplete = onComplete; |
@@ -20,10 +20,10 @@ var inherit = require('./inherit'); | ||
BriefPlayer.prototype._updateDuration = function () { | ||
var durationExtension = 0; | ||
var totalDuration = 0; | ||
var handle, playable, overflow; | ||
var handle, playable, playableDuration; | ||
for (handle = this._activePlayables.first; handle !== null; handle = handle.next) { | ||
playable = handle.object; | ||
overflow = playable._getEndTime() - this._duration; | ||
if (overflow > durationExtension) { | ||
durationExtension = overflow; | ||
playableDuration = playable._getStartTime() + playable.getDuration(); | ||
if (playableDuration > totalDuration) { | ||
totalDuration = playableDuration; | ||
} | ||
@@ -34,30 +34,17 @@ } | ||
playable = handle.object; | ||
overflow = playable._getEndTime() - this._duration; | ||
if (overflow > durationExtension) { | ||
durationExtension = overflow; | ||
playableDuration = playable._getStartTime() + playable.getDuration(); | ||
if (playableDuration > totalDuration) { | ||
totalDuration = playableDuration; | ||
} | ||
} | ||
if (durationExtension > 0) { | ||
this._extendDuration(durationExtension); | ||
} | ||
this._setDuration(totalDuration); | ||
}; | ||
BriefPlayer.prototype._onPlayableRemoved = function () { | ||
this._updateDuration(); | ||
}; | ||
BriefPlayer.prototype._onPlayableChanged = BriefPlayer.prototype._updateDuration; | ||
BriefPlayer.prototype._onPlayableRemoved = BriefPlayer.prototype._updateDuration; | ||
BriefPlayer.prototype._onPlayableChanged = function (changedPlayable) { | ||
this._warn('[BriefPlayer._onPlayableChanged] Changing a playable\'s property after attaching it to a player may have unwanted side effects', | ||
'playable:', changedPlayable, 'player:', this); | ||
// N.B The following code should work | ||
// // Updating timeline duration | ||
// var endTime = changedPlayable._startTime + changedPlayable.getDuration(); | ||
// if (endTime > this._duration) { | ||
// this._duration = endTime; | ||
// } else { | ||
// // Making sure the duration is correct | ||
// this._updateDuration(); | ||
// } | ||
}; | ||
// BriefPlayer.prototype._onPlayableChanged = function (changedPlayable) { | ||
// this._warn('[BriefPlayer._onPlayableChanged] Changing a playable\'s property after attaching it to a player may have unwanted side effects', | ||
// 'playable:', changedPlayable, 'player:', this); | ||
// }; |
@@ -149,2 +149,12 @@ /** | ||
DoublyList.prototype.getNode = function (object) { | ||
for (var node = this.first; node !== null; node = node.next) { | ||
if (node.object === object) { | ||
return node; | ||
} | ||
} | ||
return null; | ||
}; | ||
DoublyList.prototype.clear = function () { | ||
@@ -151,0 +161,0 @@ // Making sure that nodes containers are being resetted |
@@ -32,22 +32,3 @@ /** @class */ | ||
set: function (speed) { | ||
if (speed === 0) { | ||
if (this._speed !== 0) { | ||
// Setting timeStart as if new speed was 1 | ||
this._startTime += this._time / this._speed - this._time; | ||
} | ||
} else { | ||
if (this._speed === 0) { | ||
// If current speed is 0, | ||
// it corresponds to a virtual speed of 1 | ||
// when it comes to determing where the starting time is | ||
this._startTime += this._time - this._time / speed; | ||
} else { | ||
this._startTime += this._time / this._speed - this._time / speed; | ||
} | ||
} | ||
this._speed = speed; | ||
if (this._player !== null) { | ||
this._player._onPlayableChanged(this); | ||
} | ||
this.setSpeed(speed); | ||
} | ||
@@ -63,7 +44,7 @@ }); | ||
Playable.prototype.onStart = function (onStart) { this._onStart = onStart; return this; }; | ||
Playable.prototype.onUpdate = function (onUpdate) { this._onUpdate = onUpdate; return this; }; | ||
Playable.prototype.onStop = function (onStop) { this._onStop = onStop; return this; }; | ||
Playable.prototype.onPause = function (onPause) { this._onPause = onPause; return this; }; | ||
Playable.prototype.onResume = function (onResume) { this._onResume = onResume; return this; }; | ||
Playable.prototype.onStart = function (onStart) { this._onStart = onStart; return this; }; | ||
Playable.prototype.onUpdate = function (onUpdate) { this._onUpdate = onUpdate; return this; }; | ||
Playable.prototype.onStop = function (onStop) { this._onStop = onStop; return this; }; | ||
Playable.prototype.onPause = function (onPause) { this._onPause = onPause; return this; }; | ||
Playable.prototype.onResume = function (onResume) { this._onResume = onResume; return this; }; | ||
@@ -80,2 +61,30 @@ Playable.prototype.tweener = function (tweener) { | ||
Playable.prototype.setSpeed = function (speed) { | ||
if (speed < 0) { | ||
console.warn('[Playable.speed] This playable cannot have negative speed'); | ||
return; | ||
} | ||
if (speed === 0) { | ||
if (this._speed !== 0) { | ||
// Setting timeStart as if new speed was 1 | ||
this._startTime += this._time / this._speed - this._time; | ||
} | ||
} else { | ||
if (this._speed === 0) { | ||
// If current speed is 0, | ||
// it corresponds to a virtual speed of 1 | ||
// when it comes to determing where the starting time is | ||
this._startTime += this._time - this._time / speed; | ||
} else { | ||
this._startTime += this._time / this._speed - this._time / speed; | ||
} | ||
} | ||
this._speed = speed; | ||
if (this._player !== null) { | ||
this._player._onPlayableChanged(this); | ||
} | ||
}; | ||
Playable.prototype.goTo = function (timePosition, iteration) { | ||
@@ -113,26 +122,11 @@ if (this._iterations === 1) { | ||
Playable.prototype._getEndTime = function () { | ||
if (this._speed >= 0) { | ||
return Infinity; | ||
} else { | ||
return this._startTime; | ||
} | ||
return Infinity; | ||
}; | ||
Playable.prototype._getStartTime = function () { | ||
if (this._speed > 0) { | ||
return this._startTime; | ||
} else { | ||
return -Infinity; | ||
} | ||
return this._startTime; | ||
}; | ||
Playable.prototype._isWithin = function (time) { | ||
if (this._speed > 0) { | ||
return this._startTime < time; | ||
} else if (this._speed < 0) { | ||
return time < this._startTime; | ||
} else { | ||
// speed is 0 | ||
return true; | ||
} | ||
return this._startTime < time; | ||
}; | ||
@@ -179,2 +173,7 @@ | ||
Playable.prototype.stop = function () { | ||
if (this._player === null) { | ||
console.warn('[Playable.stop] Cannot stop a playable that is not running'); | ||
return; | ||
} | ||
// Stopping playable without performing any additional update nor completing | ||
@@ -181,0 +180,0 @@ if (this._player._inactivate(this) === false) { |
@@ -38,3 +38,3 @@ var Playable = require('./Playable'); | ||
Player.prototype._add = function (playable, delay) { | ||
Player.prototype._add = function (playable) { | ||
if (playable._handle === null) { | ||
@@ -44,2 +44,3 @@ // Playable can be added | ||
playable._player = this; | ||
// this._onPlayableAdded(playable); | ||
return true; | ||
@@ -102,6 +103,3 @@ } | ||
if (playable._handle.container !== this._playablesToRemove) { | ||
this._remove(playable); | ||
} | ||
this._remove(playable); | ||
this._onPlayableRemoved(playable); | ||
@@ -121,3 +119,2 @@ return this; | ||
this._handlePlayablesToRemove(); | ||
this._onAllPlayablesRemoved(); | ||
return this; | ||
@@ -146,2 +143,6 @@ }; | ||
} | ||
if ((this._activePlayables.length === 0) && (this._inactivePlayables.length === 0)) { | ||
this._onAllPlayablesRemoved(); | ||
} | ||
}; | ||
@@ -179,2 +180,7 @@ | ||
Player.prototype.stop = function () { | ||
if (this._player === null) { | ||
this._warn('[Player.stop] Cannot stop a player that is not running'); | ||
return; | ||
} | ||
// Stopping all active playables | ||
@@ -233,4 +239,5 @@ var handle = this._activePlayables.first; | ||
// Overridable methods | ||
// Player.prototype._onPlayableAdded = function (/* playable */) {}; | ||
Player.prototype._onPlayableChanged = function (/* playable */) {}; | ||
Player.prototype._onPlayableRemoved = function (/* playable */) {}; | ||
Player.prototype._onAllPlayablesRemoved = function () {}; |
@@ -1,3 +0,4 @@ | ||
var Timeline = require('./Timeline'); | ||
var Delay = require('./Delay'); | ||
var Timeline = require('./Timeline'); | ||
var Delay = require('./Delay'); | ||
var DoublyList = require('./DoublyList'); | ||
@@ -21,2 +22,4 @@ /** | ||
this._sequencedPlayables = new DoublyList(); | ||
Timeline.call(this); | ||
@@ -29,2 +32,3 @@ } | ||
Sequence.prototype.add = function (playable) { | ||
this._sequencedPlayables.addBack(playable); | ||
return Timeline.prototype.add.call(this, playable, this._duration); | ||
@@ -37,43 +41,72 @@ }; | ||
Sequence.prototype._onPlayableRemoved = function (removedPlayable) { | ||
var handle, playable; | ||
Sequence.prototype._reconstruct = function () { | ||
// O(n) | ||
var activePlayable, timeInActiveBefore; | ||
var activePlayableHandle = this._activePlayables.first; | ||
var startTime = removedPlayable._startTime; | ||
var endTime = startTime + removedPlayable.getDuration(); | ||
if (startTime > endTime) { | ||
var tmp = startTime; | ||
startTime = endTime; | ||
endTime = tmp; | ||
if (activePlayableHandle !== null) { | ||
// How far is the sequence within the active playable? | ||
activePlayable = activePlayableHandle.object; // only one active playable | ||
timeInActiveBefore = this._time - activePlayable._getStartTime(); | ||
} | ||
if (this._time < endTime) { // Playing head is before the end of the removed playable | ||
// Shifting all the playables that come after the removed playable | ||
var leftShit = endTime - this._time; | ||
for (handle = this._activePlayables.first; handle !== null; handle = handle.next) { | ||
playable = handle.object; | ||
if (removedPlayable._startTime < playable._startTime) { | ||
playable._startTime -= leftShit; | ||
} | ||
} | ||
// Reconstructing the sequence of playables | ||
var duration = 0; | ||
for (var handle = this._sequencedPlayables.first; handle !== null; handle = handle.next) { | ||
var playable = handle.object; | ||
playable._setStartTime(duration); | ||
duration = playable._getEndTime(); | ||
} | ||
for (handle = this._inactivePlayables.first; handle !== null; handle = handle.next) { | ||
playable = handle.object; | ||
if (removedPlayable._startTime < playable._startTime) { | ||
playable._startTime -= leftShit; | ||
} | ||
} | ||
if (activePlayableHandle !== null) { | ||
// Determining where to set the sequence's starting time so that the local time within | ||
// the active playable remains the same | ||
var currentStartTime = this._getStartTime(); | ||
var timeInActiveAfter = this._time - activePlayable._getStartTime(); | ||
var shift = timeInActiveBefore - timeInActiveAfter; | ||
this._startTime += shift; | ||
} | ||
if (this._time > startTime) { // Playing head is after the start of the removed playable | ||
// Shifting the starting time of the sequence | ||
var rightShift = this._time - startTime; | ||
this._startTime += rightShift; | ||
// Updating duration | ||
this._duration = duration; | ||
if (this._player !== null) { | ||
this._player._onPlayableChanged(this); | ||
} | ||
}; | ||
this._updateDuration(); | ||
Sequence.prototype.substitute = function (playableA, playableB) { | ||
// O(n) | ||
if (this._sequencedPlayables.length === 0) { | ||
this._warn('[Sequence.substitute] The sequence is empty!'); | ||
return; | ||
} | ||
// Fetching handle for playable A | ||
var handleA = this._sequencedPlayables.getNode(playableA); | ||
// Adding playable B right after playable A in this._sequencedPlayables | ||
this._sequencedPlayables.addAfter(handleA, playableB); | ||
// Adding playable B in this player | ||
this._add(playableB); | ||
// Removing playable A | ||
// Will have the effect of: | ||
// - Stopping playable A (with correct callback) | ||
// - Removing playable A from the sequence | ||
// - Reconstructing the sequence | ||
this.remove(playableA); | ||
}; | ||
// TODO: | ||
// Sequence.prototype.substitute = function (playableA, playableB) { | ||
// }; | ||
Sequence.prototype._onPlayableRemoved = function (removedPlayable) { | ||
// O(n) | ||
this._sequencedPlayables.remove(removedPlayable); | ||
if (this._sequencedPlayables.length === 0) { | ||
return; | ||
} | ||
this._reconstruct(); | ||
}; | ||
Sequence.prototype._onPlayableChanged = Sequence.prototype._reconstruct; |
Sorry, the diff of this file is too big to display
718329
7467