|
26 | 26 | getFrames: function() { return this._frames; } |
27 | 27 | }; |
28 | 28 |
|
29 | | - window.Animation = function(target, effect, timingInput) { |
| 29 | + scope.Animation = function(target, effect, timingInput) { |
30 | 30 | this.target = target; |
31 | 31 | // TODO: Make modifications to specified update the underlying player |
32 | 32 | this._timing = shared.normalizeTimingInput(timingInput); |
|
38 | 38 | else |
39 | 39 | this.effect = new KeyframeEffect(effect); |
40 | 40 | this._effect = effect; |
41 | | - this._internalPlayer = null; |
42 | 41 | this.activeDuration = shared.calculateActiveDuration(this._timing); |
43 | 42 | return this; |
44 | 43 | }; |
45 | 44 |
|
| 45 | + var originalElementAnimate = Element.prototype.animate; |
| 46 | + Element.prototype.animate = function(effect, timing) { |
| 47 | + return scope.timeline.play(new scope.Animation(this, effect, timing)); |
| 48 | + }; |
| 49 | + |
| 50 | + var nullTarget = document.createElement('div'); |
| 51 | + scope.newUnderlyingPlayerForAnimation = function(animation) { |
| 52 | + var target = animation.target || nullTarget; |
| 53 | + var effect = animation._effect; |
| 54 | + if (typeof effect == 'function') { |
| 55 | + effect = []; |
| 56 | + } |
| 57 | + return originalElementAnimate.apply(target, [effect, animation.timing]); |
| 58 | + }; |
| 59 | + |
| 60 | + scope.bindPlayerForAnimation = function(player) { |
| 61 | + if (player.source && typeof player.source.effect == 'function') { |
| 62 | + scope.bindPlayerForCustomEffect(player); |
| 63 | + } |
| 64 | + }; |
| 65 | + |
46 | 66 | var pendingGroups = []; |
47 | 67 | scope.awaitStartTime = function(groupPlayer) { |
48 | 68 | if (groupPlayer.startTime !== null || !groupPlayer._isGroup) |
|
103 | 123 | } |
104 | 124 | }; |
105 | 125 |
|
106 | | - var nullTarget = document.createElement('div'); |
107 | | - |
108 | | - window.document.timeline.play = function(source) { |
109 | | - // TODO: Handle effect callback. |
110 | | - if (source instanceof window.Animation) { |
111 | | - var target = source.target ? source.target : nullTarget; |
112 | | - var player = target.animate(source._effect, source.timing); |
113 | | - player.source = source; |
114 | | - source.player = player; |
115 | | - return player; |
116 | | - } |
117 | | - // FIXME: Move this code out of this module |
118 | | - if (source instanceof window.AnimationSequence || source instanceof window.AnimationGroup) { |
119 | | - var ticker = function(tf) { |
120 | | - if (!player.source) |
121 | | - return; |
122 | | - if (tf == null) { |
123 | | - player._removePlayers(); |
124 | | - return; |
125 | | - } |
126 | | - if (player.startTime === null) |
127 | | - return; |
128 | | - |
129 | | - player._updateChildren(); |
130 | | - }; |
131 | | - |
132 | | - var player = nullTarget.animate(ticker, source._timing); |
133 | | - player.source = source; |
134 | | - player._isGroup = true; |
135 | | - source.player = player; |
136 | | - scope.awaitStartTime(player); |
137 | | - return player; |
138 | | - } |
139 | | - }; |
140 | | - |
| 126 | + window.Animation = scope.Animation; |
141 | 127 | window.Element.prototype.getAnimationPlayers = function() { |
142 | 128 | return document.timeline.getAnimationPlayers().filter(function(player) { |
143 | | - return player._player.source !== null && player._player.source.target == this; |
| 129 | + return player.source !== null && player.source.target == this; |
144 | 130 | }.bind(this)); |
145 | 131 | }; |
146 | 132 |
|
|
0 commit comments