OLD | NEW |
1 <!-- | 1 <!-- |
2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | 2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
6 Code distributed by Google as part of the polymer project is also | 6 Code distributed by Google as part of the polymer project is also |
7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
8 --> | 8 --> |
9 | 9 |
10 <link rel="import" href="../polymer/polymer.html"> | 10 <link rel="import" href="../polymer/polymer.html"> |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // do something custom | 55 // do something custom |
56 }; | 56 }; |
57 animation.play(); | 57 animation.play(); |
58 | 58 |
59 Elements that are targets to a `core-animation` are given the `core-animation-ta
rget` class. | 59 Elements that are targets to a `core-animation` are given the `core-animation-ta
rget` class. |
60 | 60 |
61 @element core-animation | 61 @element core-animation |
62 @status beta | 62 @status beta |
63 @homepage github.io | 63 @homepage github.io |
64 --> | 64 --> |
65 <polymer-element name="core-animation" constructor="CoreAnimation" attributes="t
arget keyframes sample composite duration fill easing iterationStart iterationCo
unt delay direction autoplay targetSelector"> | 65 <polymer-element name="core-animation" constructor="CoreAnimation" attributes="t
arget keyframes customEffect composite duration fill easing iterationStart itera
tionCount delay direction autoplay targetSelector"> |
66 <script> | 66 <script> |
67 (function() { | 67 (function() { |
68 | 68 |
69 function toNumber(value, allowInfinity) { | 69 function toNumber(value, allowInfinity) { |
70 return (allowInfinity && value === 'Infinity') ? Number.POSITIVE_INFINIT
Y : Number(value); | 70 return (allowInfinity && value === 'Infinity') ? Number.POSITIVE_INFINIT
Y : Number(value); |
71 }; | 71 }; |
72 | 72 |
73 Polymer({ | 73 Polymer({ |
74 /** | 74 /** |
75 * Fired when the animation completes. | 75 * Fired when the animation completes. |
76 * | 76 * |
77 * @event core-animation-finish | 77 * @event core-animation-finish |
78 */ | 78 */ |
79 | 79 |
80 /** | 80 /** |
81 * | 81 * |
82 * Fired when the web animation object changes. | 82 * Fired when the web animation object changes. |
83 * | 83 * |
84 * @event core-animation-change | 84 * @event core-animation-change |
85 */ | 85 */ |
86 | 86 |
87 publish: { | 87 publish: { |
88 | 88 |
89 /** | 89 /** |
90 * One or more nodes to animate. | 90 * One or more nodes to animate. |
91 * | 91 * |
92 * @property target | 92 * @property target |
93 * @type HTMLElement|Node|Array<HTMLElement|Node> | 93 * @type HTMLElement|Node|Array<HTMLElement|Node> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 * equivalent to 0. | 136 * equivalent to 0. |
137 * | 137 * |
138 * @property duration | 138 * @property duration |
139 * @type number|"Infinity" | 139 * @type number|"Infinity" |
140 * @default "auto" | 140 * @default "auto" |
141 */ | 141 */ |
142 duration: {value: 'auto', reflect: true}, | 142 duration: {value: 'auto', reflect: true}, |
143 | 143 |
144 /** | 144 /** |
145 * Controls the effect the animation has on the target when it's not p
laying. | 145 * Controls the effect the animation has on the target when it's not p
laying. |
146 * The possible values are "none", "forwards", "backwards", "both" or
"auto". | 146 * The possible values are "none", "forwards", "backwards", "both" or
"auto". |
147 * | 147 * |
148 * "none" means the animation has no effect when it's not playing. | 148 * "none" means the animation has no effect when it's not playing. |
149 * | 149 * |
150 * "forward" applies the value at the end of the animation after it's
finished. | 150 * "forwards" applies the value at the end of the animation after it's
finished. |
151 * | 151 * |
152 * "backwards" applies the value at the start of the animation to the
target | 152 * "backwards" applies the value at the start of the animation to the
target |
153 * before it starts playing and has no effect when the animation finis
hes. | 153 * before it starts playing and has no effect when the animation finis
hes. |
154 * | 154 * |
155 * "both" means "forwards" and "backwards". "auto" is equivalent to "n
one". | 155 * "both" means "forwards" and "backwards". "auto" is equivalent to "n
one". |
156 * | 156 * |
157 * @property fill | 157 * @property fill |
158 * @type "none"|"forwards"|"backwards"|"both"|"auto" | 158 * @type "none"|"forwards"|"backwards"|"both"|"auto" |
159 * @default "auto" | 159 * @default "auto" |
160 */ | 160 */ |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 }, | 422 }, |
423 | 423 |
424 get animationEffect() { | 424 get animationEffect() { |
425 var props = {}; | 425 var props = {}; |
426 var frames = []; | 426 var frames = []; |
427 var effect; | 427 var effect; |
428 if (this.keyframes) { | 428 if (this.keyframes) { |
429 frames = this.keyframes; | 429 frames = this.keyframes; |
430 } else if (!this.customEffect) { | 430 } else if (!this.customEffect) { |
431 var children = this.querySelectorAll('core-animation-keyframe'); | 431 var children = this.querySelectorAll('core-animation-keyframe'); |
432 if (children.length === 0) { | 432 if (children.length === 0 && this.shadowRoot) { |
433 children = this.shadowRoot.querySelectorAll('core-animation-keyfra
me'); | 433 children = this.shadowRoot.querySelectorAll('core-animation-keyfra
me'); |
434 } | 434 } |
435 Array.prototype.forEach.call(children, function(c) { | 435 Array.prototype.forEach.call(children, function(c) { |
436 frames.push(c.properties); | 436 frames.push(c.properties); |
437 }); | 437 }); |
438 } | 438 } |
439 if (this.customEffect) { | 439 if (this.customEffect) { |
440 effect = this.customEffect; | 440 effect = this.customEffect; |
441 } else { | 441 } else { |
442 effect = new KeyframeEffect(frames, this.composite); | 442 // effect = new KeyframeEffect(frames, this.composite); |
| 443 effect = frames; |
443 } | 444 } |
444 return effect; | 445 return effect; |
445 }, | 446 }, |
446 | 447 |
447 animationFinishHandler: function() { | 448 animationFinishHandler: function() { |
448 this.fire('core-animation-finish'); | 449 this.fire('core-animation-finish'); |
449 } | 450 } |
450 | 451 |
451 }); | 452 }); |
452 })(); | 453 })(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 * The value for the CSS property. | 516 * The value for the CSS property. |
516 * | 517 * |
517 * @property value | 518 * @property value |
518 * @type string|number | 519 * @type string|number |
519 */ | 520 */ |
520 value: {value: '', reflect: true} | 521 value: {value: '', reflect: true} |
521 } | 522 } |
522 }); | 523 }); |
523 </script> | 524 </script> |
524 </polymer-element> | 525 </polymer-element> |
OLD | NEW |