Standardizing on .test() and .exec() - moving away from using .match() for RegExp...
[jquery.git] / src / fx.js
index 220b88a..65bb3f1 100644 (file)
--- a/src/fx.js
+++ b/src/fx.js
@@ -132,7 +132,7 @@ jQuery.fn.extend({
                                if ( /toggle|show|hide/.test(val) )
                                        e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
                                else {
-                                       var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
+                                       var parts = /^([+-]=)?([\d+-.]+)(.*)$/.exec(val),
                                                start = e.cur(true) || 0;
 
                                        if ( parts ) {
@@ -286,20 +286,8 @@ jQuery.fx.prototype = {
 
                t.elem = this.elem;
 
-               if ( t() && jQuery.timers.push(t) && !timerId ) {
-                       timerId = setInterval(function(){
-                               var timers = jQuery.timers;
-
-                               for ( var i = 0; i < timers.length; i++ )
-                                       if ( !timers[i]() )
-                                               timers.splice(i--, 1);
-
-                               if ( !timers.length ) {
-                                       clearInterval( timerId );
-                                       timerId = undefined;
-                               }
-                       }, 13);
-               }
+               if ( t() && jQuery.timers.push(t) && !timerId )
+                       timerId = setInterval(jQuery.fx.tick, 13);
        },
 
        // Simple 'show' function
@@ -386,12 +374,30 @@ jQuery.fx.prototype = {
 };
 
 jQuery.extend( jQuery.fx, {
+
+       tick:function(){
+               var timers = jQuery.timers;
+
+               for ( var i = 0; i < timers.length; i++ )
+                       if ( !timers[i]() )
+                               timers.splice(i--, 1);
+
+               if ( !timers.length )
+                       jQuery.fx.stop();
+       },
+               
+       stop:function(){
+               clearInterval( timerId );
+               timerId = null;
+       },
+       
        speeds:{
                slow: 600,
                fast: 200,
                // Default speed
                _default: 400
        },
+
        step: {
 
                opacity: function(fx){