This repository was archived by the owner on Mar 13, 2018. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4646 * @class polymer-animation
4747 */
4848 /**
49- * Fired when an animation completes
50- * @event complete
49+ * Fired when the animation starts
50+ * @event animation-start
51+ *
52+ * Fired when the animation completes
53+ * @event animation-end
54+ *
5155 */
5256 Polymer ( 'polymer-animation' , {
5357 publish : {
145149 //this.animation && console.log('play', this.animation);
146150 if ( this . animation ) {
147151 this . cancel ( ) ;
148- if ( ! this . animation . onend ) {
149- this . animation . onend = this . complete . bind ( this ) ;
150- }
152+ this . bindAnimationEvents ( ) ;
151153 this . player = document . timeline . play ( this . animation ) ;
152- this . player . paused = false ;
153- this . player . currentTime = 0 ;
154154 }
155155 } ) ;
156156 } ,
262262 }
263263 return new KeyframeAnimationEffect ( frames , this . composite ) ;
264264 } ,
265- // intended for user implementation
266- complete : function ( ) {
267- this . fire ( 'complete' ) ;
265+ bindAnimationEvents : function ( ) {
266+ if ( ! this . animation . onstart ) {
267+ this . animation . onstart = this . animationStartHandler . bind ( this ) ;
268+ }
269+ if ( ! this . animation . onend ) {
270+ this . animation . onend = this . animationEndHandler . bind ( this ) ;
271+ }
272+ } ,
273+ animationStartHandler : function ( ) {
274+ this . fire ( 'animation-start' ) ;
275+ } ,
276+ animationEndHandler : function ( ) {
277+ this . fire ( 'animation-end' ) ;
268278 }
269279 } ) ;
270280 } ) ( ) ;
You can’t perform that action at this time.
0 commit comments