diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2012-06-26 13:48:31 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-07-05 21:38:17 -0400 |
commit | 1793eab32bc8a00b2ad041c9b10ad3bdd2bec702 (patch) | |
tree | 306168bf4d6ba1c284edea56fa18fe597a468da6 /test/unit/effects.js | |
parent | 86b775d036627ebd7242fbb4eb9f24e4ba1fa9c5 (diff) | |
download | jquery-1793eab32bc8a00b2ad041c9b10ad3bdd2bec702.tar.gz jquery-1793eab32bc8a00b2ad041c9b10ad3bdd2bec702.zip |
Fix #11971: force numeric animation start to be numeric, closes gh-836.
Diffstat (limited to 'test/unit/effects.js')
-rw-r--r-- | test/unit/effects.js | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/test/unit/effects.js b/test/unit/effects.js index 57fa8c966..402a7a587 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -1677,13 +1677,40 @@ asyncTest( "animate does not change start value for non-px animation (#7109)", 1 }); }); -asyncTest("Animation callbacks (#11797)", 12, function() { +asyncTest( "non-px animation handles non-numeric start (#11971)", 2, function() { + var foo = jQuery("#foo"), + initial = foo.css("backgroundPositionX"); + + foo.animate({ backgroundPositionX: "42%" }, { + duration: 1, + progress: function( anim, percent ) { + if ( percent ) { + return; + } + + if ( parseFloat( initial ) ) { + equal( jQuery.style( this, "backgroundPositionX" ), initial, "Numeric start preserved" ); + } else { + equal( jQuery.style( this, "backgroundPositionX" ), "0%", "Non-numeric start zeroed" ); + } + }, + done: function() { + equal( jQuery.style( this, "backgroundPositionX" ), "42%", "End reached" ); + start(); + } + }); +}); + +asyncTest("Animation callbacks (#11797)", 15, function() { var targets = jQuery("#foo").children(), done = false, expectedProgress = 0; targets.eq( 0 ).animate( {}, { duration: 1, + start: function() { + ok( true, "empty: start" ); + }, progress: function( anim, percent ) { equal( percent, 0, "empty: progress 0" ); }, @@ -1699,13 +1726,16 @@ asyncTest("Animation callbacks (#11797)", 12, function() { } }); - ok( done, "animation done" ); + ok( done, "empty: done immediately" ); done = false; targets.eq( 1 ).animate({ opacity: 0 }, { duration: 1, + start: function() { + ok( true, "stopped: start" ); + }, progress: function( anim, percent ) { equal( percent, 0, "stopped: progress 0" ); }, @@ -1721,12 +1751,15 @@ asyncTest("Animation callbacks (#11797)", 12, function() { } }).stop(); - ok( done, "animation stopped" ); + ok( done, "stopped: stopped immediately" ); targets.eq( 2 ).animate({ opacity: 0 }, { duration: 1, + start: function() { + ok( true, "async: start" ); + }, progress: function( anim, percent ) { equal( percent, expectedProgress, "async: progress " + expectedProgress ); // once at 0, once at 1 |