delay.js (534B)
1 define( [ 2 "../core", 3 "../queue", 4 "../effects" // Delay is optional because of this dependency 5 ], function( jQuery ) { 6 7 "use strict"; 8 9 // Based off of the plugin by Clint Helfers, with permission. 10 jQuery.fn.delay = function( time, type ) { 11 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; 12 type = type || "fx"; 13 14 return this.queue( type, function( next, hooks ) { 15 var timeout = window.setTimeout( next, time ); 16 hooks.stop = function() { 17 window.clearTimeout( timeout ); 18 }; 19 } ); 20 }; 21 22 return jQuery.fn.delay; 23 } );