Commit c436ae04 authored by Corey Frang's avatar Corey Frang Committed by Dave Methvin

Completes #11799: Maybe .progress() was cooler than I thought.

Generate a .progress() for each step of an animation, once all properties are changed. Closes gh-835.
parent a2758377
...@@ -91,6 +91,8 @@ function Animation( elem, properties, options ) { ...@@ -91,6 +91,8 @@ function Animation( elem, properties, options ) {
animation.tweens[ index ].run( percent ); animation.tweens[ index ].run( percent );
} }
deferred.notifyWith( elem, [ animation, percent, remaining ]);
if ( percent < 1 && length ) { if ( percent < 1 && length ) {
return remaining; return remaining;
} else { } else {
...@@ -159,7 +161,8 @@ function Animation( elem, properties, options ) { ...@@ -159,7 +161,8 @@ function Animation( elem, properties, options ) {
); );
// attach callbacks from options // attach callbacks from options
return animation.done( animation.opts.done, animation.opts.complete ) return animation.progress( animation.opts.progress )
.done( animation.opts.done, animation.opts.complete )
.fail( animation.opts.fail ) .fail( animation.opts.fail )
.always( animation.opts.always ); .always( animation.opts.always );
} }
......
...@@ -1665,12 +1665,16 @@ asyncTest( "animate does not change start value for non-px animation (#7109)", 1 ...@@ -1665,12 +1665,16 @@ asyncTest( "animate does not change start value for non-px animation (#7109)", 1
}); });
}); });
asyncTest("Animation callbacks (#11797)", 8, function() { asyncTest("Animation callbacks (#11797)", 12, function() {
var targets = jQuery("#foo").children(), var targets = jQuery("#foo").children(),
done = false; done = false,
expectedProgress = 0;
targets.eq( 0 ).animate( {}, { targets.eq( 0 ).animate( {}, {
duration: 10, duration: 1,
progress: function( anim, percent ) {
equal( percent, 0, "empty: progress 0" );
},
done: function() { done: function() {
ok( true, "empty: done" ); ok( true, "empty: done" );
}, },
...@@ -1689,7 +1693,10 @@ asyncTest("Animation callbacks (#11797)", 8, function() { ...@@ -1689,7 +1693,10 @@ asyncTest("Animation callbacks (#11797)", 8, function() {
targets.eq( 1 ).animate({ targets.eq( 1 ).animate({
opacity: 0 opacity: 0
}, { }, {
duration: 10, duration: 1,
progress: function( anim, percent ) {
equal( percent, 0, "stopped: progress 0" );
},
done: function() { done: function() {
ok( false, "stopped: done" ); ok( false, "stopped: done" );
}, },
...@@ -1707,7 +1714,12 @@ asyncTest("Animation callbacks (#11797)", 8, function() { ...@@ -1707,7 +1714,12 @@ asyncTest("Animation callbacks (#11797)", 8, function() {
targets.eq( 2 ).animate({ targets.eq( 2 ).animate({
opacity: 0 opacity: 0
}, { }, {
duration: 10, duration: 1,
progress: function( anim, percent ) {
equal( percent, expectedProgress, "async: progress " + expectedProgress );
// once at 0, once at 1
expectedProgress++;
},
done: function() { done: function() {
ok( true, "async: done" ); ok( true, "async: done" );
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment