]> source.dussan.org Git - jquery.git/commitdiff
Fix #12803. Add jQuery.fx.start as a hook point. Close gh-1024.
authorCorey Frang <gnarf@gnarf.net>
Thu, 8 Nov 2012 06:02:14 +0000 (00:02 -0600)
committerDave Methvin <dave.methvin@gmail.com>
Sun, 25 Nov 2012 20:23:02 +0000 (15:23 -0500)
src/effects.js
test/unit/effects.js

index bfe282aa5610de0f02c0e588b79e09f6d1edc566..d5ff7464c549132ea7639b8fea48ca9cab10c2b6 100644 (file)
@@ -640,13 +640,19 @@ jQuery.fx.tick = function() {
 };
 
 jQuery.fx.timer = function( timer ) {
-       if ( timer() && jQuery.timers.push( timer ) && !timerId ) {
-               timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
+       if ( timer() && jQuery.timers.push( timer ) ) {
+               jQuery.fx.start();
        }
 };
 
 jQuery.fx.interval = 13;
 
+jQuery.fx.start = function() {
+       if ( !timerId ) {
+               timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
+       }
+};
+
 jQuery.fx.stop = function() {
        clearInterval( timerId );
        timerId = null;
index af2eddc4eecb06e6ec24ac31c4dfdc1eaab89378..b615dfd6dfb412756a9cb42b0f1c6542c566e295 100644 (file)
@@ -1877,4 +1877,31 @@ jQuery.map([ "toggle", "slideToggle", "fadeToggle" ], function ( method ) {
        });
 });
 
+test( "jQuery.fx.start & jQuery.fx.stop hook points", function() {
+       var oldStart = jQuery.fx.start,
+               oldStop = jQuery.fx.stop,
+               foo = jQuery({ foo: 0 });
+
+       expect( 3 );
+
+       jQuery.fx.start = function() {
+               ok( true, "start called" );
+       };
+       jQuery.fx.stop = function() {
+               ok( true, "stop called" );
+       };
+
+       // calls start
+       foo.animate({ foo: 1 }, { queue: false });
+       // calls start
+       foo.animate({ foo: 2 }, { queue: false });
+       foo.stop();
+       // calls stop
+       jQuery.fx.tick();
+
+       // cleanup
+       jQuery.fx.start = oldStart;
+       jQuery.fx.stop = oldStop;
+});
+
 } // if ( jQuery.fx )