@@ -45,6 +45,13 @@ function css3TransitionsHandler( name, reverse, $to, $from ) {
4545 // for this notification that will never come.
4646
4747 doneTimer = 0 ,
48+
49+ // We use a timer to place the 'animate' class on the 'to' and
50+ // 'from' elements to kick-off any CSS3 transitions. We need to
51+ // track the timer id so we can kill it, just in case the doneFunc
52+ // fires.
53+
54+ animateTimer = 0 ,
4855
4956 // When the transition completes, we need to do some clean-up
5057 // of the CSS classes we placed on the "to" and "from" elements.
@@ -61,6 +68,14 @@ function css3TransitionsHandler( name, reverse, $to, $from ) {
6168 doneTimer = 0 ;
6269 }
6370
71+ // Make sure to clear the animation timer just in
72+ // case the doneFunc fires before it does.
73+
74+ if ( animateTimer ) {
75+ clearTimeout ( animateTimer ) ;
76+ animateTimer = 0 ;
77+ }
78+
6479 // Only one page can ever have the activePageClass on it,
6580 // so remove it from the "from" element and then place it
6681 // on the "to" element.
@@ -115,8 +130,9 @@ function css3TransitionsHandler( name, reverse, $to, $from ) {
115130 // rules for the "to" and "from" elements that specify new CSS property values
116131 // that will kick-off the transitions.
117132
118- setTimeout ( function ( ) {
119- $both . addClass ( "animate" ) ;
133+ animateTimer = setTimeout ( function ( ) {
134+ animateTimer = 0 ;
135+ $both . addClass ( "animate" ) ;
120136 } , css3TransitionsHandler . animateClassInterval ) ;
121137
122138 // After we've set up and started the transitions, return a promise to the
0 commit comments