Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: polymer_0.5.4/bower_components/web-animations-js/src/animation-constructor.js

Issue 895523005: Added Polymer 0.5.4 (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 Google Inc. All rights reserved. 1 // Copyright 2014 Google Inc. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 10 matching lines...) Expand all
21 function KeyframeEffect(effect) { 21 function KeyframeEffect(effect) {
22 this._frames = shared.normalizeKeyframes(effect); 22 this._frames = shared.normalizeKeyframes(effect);
23 } 23 }
24 24
25 KeyframeEffect.prototype = { 25 KeyframeEffect.prototype = {
26 getFrames: function() { return this._frames; } 26 getFrames: function() { return this._frames; }
27 }; 27 };
28 28
29 scope.Animation = function(target, effect, timingInput) { 29 scope.Animation = function(target, effect, timingInput) {
30 this.target = target; 30 this.target = target;
31 // TODO: Make modifications to specified update the underlying player 31
32 // TODO: Store a clone, not the same instance.
33 this._timingInput = timingInput;
32 this._timing = shared.normalizeTimingInput(timingInput); 34 this._timing = shared.normalizeTimingInput(timingInput);
35
36 // TODO: Make modifications to timing update the underlying player
33 this.timing = shared.makeTiming(timingInput); 37 this.timing = shared.makeTiming(timingInput);
34 // TODO: Make this a live object - will need to separate normalization of 38 // TODO: Make this a live object - will need to separate normalization of
35 // keyframes into a shared module. 39 // keyframes into a shared module.
36 if (typeof effect == 'function') 40 if (typeof effect == 'function')
37 this.effect = effect; 41 this.effect = effect;
38 else 42 else
39 this.effect = new KeyframeEffect(effect); 43 this.effect = new KeyframeEffect(effect);
40 this._effect = effect; 44 this._effect = effect;
41 this.activeDuration = shared.calculateActiveDuration(this._timing); 45 this.activeDuration = shared.calculateActiveDuration(this._timing);
42 return this; 46 return this;
43 }; 47 };
44 48
45 var originalElementAnimate = Element.prototype.animate; 49 var originalElementAnimate = Element.prototype.animate;
46 Element.prototype.animate = function(effect, timing) { 50 Element.prototype.animate = function(effect, timing) {
47 return scope.timeline.play(new scope.Animation(this, effect, timing)); 51 return scope.timeline.play(new scope.Animation(this, effect, timing));
48 }; 52 };
49 53
50 var nullTarget = document.createElement('div'); 54 var nullTarget = document.createElementNS('http://www.w3.org/1999/xhtml', 'div ');
51 scope.newUnderlyingPlayerForAnimation = function(animation) { 55 scope.newUnderlyingPlayerForAnimation = function(animation) {
52 var target = animation.target || nullTarget; 56 var target = animation.target || nullTarget;
53 var effect = animation._effect; 57 var effect = animation._effect;
54 if (typeof effect == 'function') { 58 if (typeof effect == 'function') {
55 effect = []; 59 effect = [];
56 } 60 }
57 return originalElementAnimate.apply(target, [effect, animation.timing]); 61 return originalElementAnimate.apply(target, [effect, animation._timingInput] );
58 }; 62 };
59 63
60 scope.bindPlayerForAnimation = function(player) { 64 scope.bindPlayerForAnimation = function(player) {
61 if (player.source && typeof player.source.effect == 'function') { 65 if (player.source && typeof player.source.effect == 'function') {
62 scope.bindPlayerForCustomEffect(player); 66 scope.bindPlayerForCustomEffect(player);
63 } 67 }
64 }; 68 };
65 69
66 var pendingGroups = []; 70 var pendingGroups = [];
67 scope.awaitStartTime = function(groupPlayer) { 71 scope.awaitStartTime = function(groupPlayer) {
(...skipping 19 matching lines...) Expand all
87 value: function() { 91 value: function() {
88 var result = originalGetComputedStyle.apply(this, arguments); 92 var result = originalGetComputedStyle.apply(this, arguments);
89 if (updatePendingGroups()) 93 if (updatePendingGroups())
90 result = originalGetComputedStyle.apply(this, arguments); 94 result = originalGetComputedStyle.apply(this, arguments);
91 return result; 95 return result;
92 }, 96 },
93 }); 97 });
94 98
95 // TODO: Call into this less frequently. 99 // TODO: Call into this less frequently.
96 scope.Player.prototype._updateChildren = function() { 100 scope.Player.prototype._updateChildren = function() {
97 if (this.startTime === null || !this.source || !this._isGroup) 101 if (this.paused || !this.source || !this._isGroup)
98 return; 102 return;
99 var offset = this.source._timing.delay; 103 var offset = this.source._timing.delay;
100 for (var i = 0; i < this.source.children.length; i++) { 104 for (var i = 0; i < this.source.children.length; i++) {
101 var child = this.source.children[i]; 105 var child = this.source.children[i];
102 var childPlayer; 106 var childPlayer;
103 107
104 if (i >= this._childPlayers.length) { 108 if (i >= this._childPlayers.length) {
105 childPlayer = window.document.timeline.play(child); 109 childPlayer = window.document.timeline.play(child);
106 child.player = this.source.player;
107 this._childPlayers.push(childPlayer); 110 this._childPlayers.push(childPlayer);
108 } else { 111 } else {
109 childPlayer = this._childPlayers[i]; 112 childPlayer = this._childPlayers[i];
110 } 113 }
114 child.player = this.source.player;
111 115
112 if (childPlayer.startTime != this.startTime + offset) { 116 if (childPlayer.startTime != this.startTime + offset) {
113 childPlayer.startTime = this.startTime + offset; 117 if (this.startTime === null) {
118 childPlayer.currentTime = this.source.player.currentTime - offset;
119 childPlayer._startTime = null;
120 } else {
121 childPlayer.startTime = this.startTime + offset;
122 }
114 childPlayer._updateChildren(); 123 childPlayer._updateChildren();
115 } 124 }
116 125
117 if (this.playbackRate == -1 && this.currentTime < offset && childPlayer.cu rrentTime !== -1) { 126 if (this.playbackRate == -1 && this.currentTime < offset && childPlayer.cu rrentTime !== -1) {
118 childPlayer.currentTime = -1; 127 childPlayer.currentTime = -1;
119 } 128 }
120 129
121 if (this.source instanceof window.AnimationSequence) 130 if (this.source instanceof window.AnimationSequence)
122 offset += groupChildDuration(child); 131 offset += groupChildDuration(child);
123 } 132 }
124 }; 133 };
125 134
126 window.Animation = scope.Animation; 135 window.Animation = scope.Animation;
127 window.Element.prototype.getAnimationPlayers = function() { 136 window.Element.prototype.getAnimationPlayers = function() {
128 return document.timeline.getAnimationPlayers().filter(function(player) { 137 return document.timeline.getAnimationPlayers().filter(function(player) {
129 return player.source !== null && player.source.target == this; 138 return player.source !== null && player.source.target == this;
130 }.bind(this)); 139 }.bind(this));
131 }; 140 };
132 141
133 scope.groupChildDuration = groupChildDuration; 142 scope.groupChildDuration = groupChildDuration;
134 143
135 }(webAnimationsShared, webAnimationsMaxifill, webAnimationsTesting)); 144 }(webAnimationsShared, webAnimationsNext, webAnimationsTesting));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698