Skip to content

Commit 6b6b4f3

Browse files
committed
Fixed intermittent failure that for 1st test when checking to make sure all animation classes were removed.
- Make sure to kill the timer used to place the 'animate' class on the 'from' and 'to' elements, just in case the doneFunc() callback fires first.
1 parent 0ab9e27 commit 6b6b4f3

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

js/jquery.mobile.transition.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)