mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
!function(shared,scope,testing){function webAnimationsNextTick(t){var timeline=window.document.timeline;timeline.currentTime=t,timeline._discardAnimations(),0==timeline._animations.length?ticking=!1:requestAnimationFrame(webAnimationsNextTick)}scope.AnimationTimeline=function(){this._animations=[],this.currentTime=void 0},scope.AnimationTimeline.prototype={getAnimations:function(){return this._discardAnimations(),this._animations.slice()},getAnimationPlayers:function(){return shared.deprecated("AnimationTimeline.getAnimationPlayers","2015-03-23","Use AnimationTimeline.getAnimations instead."),this.getAnimations()},_discardAnimations:function(){this._animations=this._animations.filter(function(animation){return"finished"!=animation.playState&&"idle"!=animation.playState})},play:function(effect){var animation=new scope.Animation(effect);return this._animations.push(animation),scope.restartWebAnimationsNextTick(),animation._animation.play(),animation}};var ticking=!1;scope.restartWebAnimationsNextTick=function(){ticking||(ticking=!0,requestAnimationFrame(webAnimationsNextTick))};var timeline=new scope.AnimationTimeline;scope.timeline=timeline;try{Object.defineProperty(window.document,"timeline",{configurable:!0,get:function(){return timeline}})}catch(e){}try{window.document.timeline=timeline}catch(e){}}(webAnimationsShared,webAnimationsNext,webAnimationsTesting),function(shared,scope,testing){scope.Animation=function(effect){this.effect=effect,effect&&(effect.animation=this),this._isGroup=!1,this._animation=null,this._childAnimations=[],this._callback=null,this._rebuildUnderlyingAnimation(),this._animation.cancel()},scope.Animation.prototype={_rebuildUnderlyingAnimation:function(){this._animation&&(this._animation.cancel(),this._animation=null),(!this.effect||this.effect instanceof window.KeyframeEffect)&&(this._animation=scope.newUnderlyingAnimationForKeyframeEffect(this.effect),scope.bindAnimationForKeyframeEffect(this)),(this.effect instanceof window.SequenceEffect||this.effect instanceof window.GroupEffect)&&(this._animation=scope.newUnderlyingAnimationForGroup(this.effect),scope.bindAnimationForGroup(this))},_updateChildren:function(){if(this.effect&&"idle"!=this.playState){var offset=this.effect._timing.delay;this._childAnimations.forEach(function(childAnimation){this._arrangeChildren(childAnimation,offset),this.effect instanceof window.SequenceEffect&&(offset+=scope.groupChildDuration(childAnimation.effect))}.bind(this))}},_setExternalAnimation:function(animation){if(this.effect&&this._isGroup)for(var i=0;i<this.effect.children.length;i++)this.effect.children[i].animation=animation,this._childAnimations[i]._setExternalAnimation(animation)},_constructChildren:function(){if(this.effect&&this._isGroup){var offset=this.effect._timing.delay;this.effect.children.forEach(function(child){var childAnimation=window.document.timeline.play(child);this._childAnimations.push(childAnimation),childAnimation.playbackRate=this.playbackRate,this.paused&&childAnimation.pause(),child.animation=this.effect.animation,this._arrangeChildren(childAnimation,offset),this.effect instanceof window.SequenceEffect&&(offset+=scope.groupChildDuration(child))}.bind(this))}},_arrangeChildren:function(childAnimation,offset){null===this.startTime?(childAnimation.currentTime=this.currentTime-offset/this.playbackRate,childAnimation._startTime=null):childAnimation.startTime!==this.startTime+offset/this.playbackRate&&(childAnimation.startTime=this.startTime+offset/this.playbackRate)},get paused(){return this._animation.paused},get playState(){return this._animation.playState},get onfinish(){return this._onfinish},set onfinish(v){"function"==typeof v?(this._onfinish=v,this._animation.onfinish=function(e){e.target=this,v.call(this,e)}.bind(this)):(this._animation.onfinish=v,this.onfinish=this._animation.onfinish)},get currentTime(){return this._animation.currentTime},set currentTime(v){this._animation.currentTime=v,this._register(),this._forEachChild(function(child,offset){child.currentTime=v-offset})},get startTime(){return this._animation.startTime},set startTime(v){this._animation.startTime=v,this._register(),this._forEachChild(function(child,offset){child.startTime=v+offset})},get playbackRate(){return this._animation.playbackRate},set playbackRate(value){var oldCurrentTime=this.currentTime;this._animation.playbackRate=value,this._forEachChild(function(childAnimation){childAnimation.playbackRate=value}),"paused"!=this.playState&&"idle"!=this.playState&&this.play(),null!==oldCurrentTime&&(this.currentTime=oldCurrentTime)},get finished(){return this._animation.finished},get source(){return shared.deprecated("Animation.source","2015-03-23","Use Animation.effect instead."),this.effect},play:function(){this._animation.play(),this._register(),scope.awaitStartTime(this),this._forEachChild(function(child){var time=child.currentTime;child.play(),child.currentTime=time})},pause:function(){this._animation.pause(),this._register(),this._forEachChild(function(child){child.pause()})},finish:function(){this._animation.finish(),this._register()},cancel:function(){this._animation.cancel(),this._register(),this._removeChildren()},reverse:function(){var oldCurrentTime=this.currentTime;this._animation.reverse(),this._forEachChild(function(childAnimation){childAnimation.reverse()}),null!==oldCurrentTime&&(this.currentTime=oldCurrentTime)},addEventListener:function(type,handler){var wrapped=handler;"function"==typeof handler&&(wrapped=function(e){e.target=this,handler.call(this,e)}.bind(this),handler._wrapper=wrapped),this._animation.addEventListener(type,wrapped)},removeEventListener:function(type,handler){this._animation.removeEventListener(type,handler&&handler._wrapper||handler)},_removeChildren:function(){for(;this._childAnimations.length;)this._childAnimations.pop().cancel()},_forEachChild:function(f){var offset=0;if(this.effect.children&&this._childAnimations.length<this.effect.children.length&&this._constructChildren(),this._childAnimations.forEach(function(child){f.call(this,child,offset),this.effect instanceof window.SequenceEffect&&(offset+=child.effect.activeDuration)}.bind(this)),"pending"!=this._animation.playState){var timing=this.effect._timing,t=this._animation.currentTime;null!==t&&(t=shared.calculateTimeFraction(shared.calculateActiveDuration(timing),t,timing)),(null==t||isNaN(t))&&this._removeChildren()}}}}(webAnimationsShared,webAnimationsNext,webAnimationsTesting),function(shared,scope,testing){function KeyframeList(effectInput){this._frames=shared.normalizeKeyframes(effectInput)}function updatePendingGroups(){for(var updated=!1;pendingGroups.length;)pendingGroups.shift()._updateChildren(),updated=!0;return updated}scope.KeyframeEffect=function(target,effectInput,timingInput){return this.target=target,this._timingInput=timingInput,this._timing=shared.normalizeTimingInput(timingInput),this.timing=shared.makeTiming(timingInput),"function"==typeof effectInput?this._normalizedKeyframes=effectInput:this._normalizedKeyframes=new KeyframeList(effectInput),this._keyframes=effectInput,this.activeDuration=shared.calculateActiveDuration(this._timing),this},scope.KeyframeEffect.prototype={getFrames:function(){return"function"==typeof this._normalizedKeyframes?this._normalizedKeyframes:this._normalizedKeyframes._frames},get effect(){return shared.deprecated("KeyframeEffect.effect","2015-03-23","Use KeyframeEffect.getFrames() instead."),this._normalizedKeyframes}};var originalElementAnimate=Element.prototype.animate;Element.prototype.animate=function(effectInput,timing){return scope.timeline.play(new scope.KeyframeEffect(this,effectInput,timing))};var nullTarget=document.createElementNS("http://www.w3.org/1999/xhtml","div");scope.newUnderlyingAnimationForKeyframeEffect=function(keyframeEffect){var target=keyframeEffect.target||nullTarget,keyframes=keyframeEffect._keyframes;return"function"==typeof keyframes&&(keyframes=[]),originalElementAnimate.apply(target,[keyframes,keyframeEffect._timingInput])},scope.bindAnimationForKeyframeEffect=function(animation){animation.effect&&"function"==typeof animation.effect._normalizedKeyframes&&scope.bindAnimationForCustomEffect(animation)};var pendingGroups=[];scope.awaitStartTime=function(groupAnimation){null===groupAnimation.startTime&&groupAnimation._isGroup&&(0==pendingGroups.length&&requestAnimationFrame(updatePendingGroups),pendingGroups.push(groupAnimation))};var originalGetComputedStyle=window.getComputedStyle;Object.defineProperty(window,"getComputedStyle",{configurable:!0,enumerable:!0,value:function(){var result=originalGetComputedStyle.apply(this,arguments);return updatePendingGroups()&&(result=originalGetComputedStyle.apply(this,arguments)),result}}),window.KeyframeEffect=scope.KeyframeEffect,window.Element.prototype.getAnimations=function(){return document.timeline.getAnimations().filter(function(animation){return null!==animation.effect&&animation.effect.target==this}.bind(this))},window.Element.prototype.getAnimationPlayers=function(){return shared.deprecated("Element.getAnimationPlayers","2015-03-23","Use Element.getAnimations instead."),this.getAnimations()},window.Animation=function(){shared.deprecated("window.Animation","2015-03-23","Use window.KeyframeEffect instead."),window.KeyframeEffect.apply(this,arguments)},window.Animation.prototype=Object.create(window.KeyframeEffect.prototype),window.Animation.prototype.constructor=window.Animation}(webAnimationsShared,webAnimationsNext,webAnimationsTesting),function(shared,scope,testing){function register(callback){callback._registered||(callback._registered=!0,callbacks.push(callback),ticking||(ticking=!0,requestAnimationFrame(tick)))}function tick(t){var updating=callbacks;callbacks=[],updating.sort(function(left,right){return left._sequenceNumber-right._sequenceNumber}),updating=updating.filter(function(callback){callback();var playState=callback._animation?callback._animation.playState:"idle";return"running"!=playState&&"pending"!=playState&&(callback._registered=!1),callback._registered}),callbacks.push.apply(callbacks,updating),callbacks.length?(ticking=!0,requestAnimationFrame(tick)):ticking=!1}var sequenceNumber=(document.createElementNS("http://www.w3.org/1999/xhtml","div"),0);scope.bindAnimationForCustomEffect=function(animation){var target=animation.effect.target,effectFunction=animation.effect._normalizedKeyframes,timing=animation.effect.timing,last=null;timing=shared.normalizeTimingInput(timing);var callback=function(){var t=callback._animation?callback._animation.currentTime:null;null!==t&&(t=shared.calculateTimeFraction(shared.calculateActiveDuration(timing),t,timing),isNaN(t)&&(t=null)),t!==last&&effectFunction(t,target,animation.effect),last=t};callback._animation=animation,callback._registered=!1,callback._sequenceNumber=sequenceNumber++,animation._callback=callback,register(callback)};var callbacks=[],ticking=!1;scope.Animation.prototype._register=function(){this._callback&®ister(this._callback)}}(webAnimationsShared,webAnimationsNext,webAnimationsTesting),function(shared,scope,testing){function groupChildDuration(node){return node._timing.delay+node.activeDuration+node._timing.endDelay}function constructor(children,timingInput){this.children=children||[],this._timing=shared.normalizeTimingInput(timingInput,!0),this.timing=shared.makeTiming(timingInput,!0),"auto"===this._timing.duration&&(this._timing.duration=this.activeDuration)}window.SequenceEffect=function(){constructor.apply(this,arguments)},window.GroupEffect=function(){constructor.apply(this,arguments)},window.SequenceEffect.prototype={get activeDuration(){var total=0;return this.children.forEach(function(child){total+=groupChildDuration(child)}),Math.max(total,0)}},window.GroupEffect.prototype={get activeDuration(){var max=0;return this.children.forEach(function(child){max=Math.max(max,groupChildDuration(child))}),max}},scope.newUnderlyingAnimationForGroup=function(group){var underlyingAnimation,timing=null,ticker=function(tf){var animation=underlyingAnimation._wrapper;if("pending"!=animation.playState&&animation.effect)return null==tf?void animation._removeChildren():0==tf&&animation.playbackRate<0&&(timing||(timing=shared.normalizeTimingInput(animation.effect.timing)),tf=shared.calculateTimeFraction(shared.calculateActiveDuration(timing),-1,timing),isNaN(tf)||null==tf)?(animation._forEachChild(function(child){child.currentTime=-1}),void animation._removeChildren()):void 0};return underlyingAnimation=scope.timeline.play(new scope.KeyframeEffect(null,ticker,group._timing))},scope.bindAnimationForGroup=function(animation){animation._animation._wrapper=animation,animation._isGroup=!0,scope.awaitStartTime(animation),animation._constructChildren(),animation._setExternalAnimation(animation)},scope.groupChildDuration=groupChildDuration,window.AnimationSequence=function(){shared.deprecated("window.AnimationSequence","2015-03-23","Use window.SequenceEffect instead."),window.SequenceEffect.apply(this,arguments)},window.AnimationSequence.prototype=Object.create(window.SequenceEffect.prototype),window.AnimationSequence.prototype.constructor=window.AnimationSequence,window.AnimationGroup=function(){shared.deprecated("window.AnimationGroup","2015-03-23","Use window.GroupEffect instead."),window.GroupEffect.apply(this,arguments)},window.AnimationGroup.prototype=Object.create(window.GroupEffect.prototype),window.AnimationGroup.prototype.constructor=window.AnimationGroup}(webAnimationsShared,webAnimationsNext,webAnimationsTesting);
|
|
//# sourceMappingURL=inter-component-web-animations-next-lite.js.map
|