diff options
author | gnarf <gnarf@gnarf.net> | 2011-06-21 00:23:52 -0500 |
---|---|---|
committer | gnarf <gnarf@gnarf.net> | 2011-06-21 01:18:01 -0500 |
commit | 1c1a3b1a361d90a73755fbd038b3cdfb0960c29f (patch) | |
tree | f86c98826a6c72421c9bc20b4e75855598bebf34 /ui/jquery.effects.pulsate.js | |
parent | fb210ae1ec16cefb1e4d4dfaf7d55499cac53ab8 (diff) | |
download | jquery-ui-1c1a3b1a361d90a73755fbd038b3cdfb0960c29f.tar.gz jquery-ui-1c1a3b1a361d90a73755fbd038b3cdfb0960c29f.zip |
Effects.*: Updating Effect Method API to avoid duplicating the queue call - Fixes #7318 - Add the queue functions to $.fn.effect()
Diffstat (limited to 'ui/jquery.effects.pulsate.js')
-rw-r--r-- | ui/jquery.effects.pulsate.js | 78 |
1 files changed, 38 insertions, 40 deletions
diff --git a/ui/jquery.effects.pulsate.js b/ui/jquery.effects.pulsate.js index a0ddf51fd..bc257f624 100644 --- a/ui/jquery.effects.pulsate.js +++ b/ui/jquery.effects.pulsate.js @@ -12,56 +12,54 @@ */ (function( $, undefined ) { -$.effects.effect.pulsate = function( o ) { - return this.queue( function( next ) { - var elem = $( this ), - mode = $.effects.setMode( elem, o.mode || "show" ), - show = mode === "show", - hide = mode === "hide", - showhide = ( show || mode === "hide" ), +$.effects.effect.pulsate = function( o, next ) { + var elem = $( this ), + mode = $.effects.setMode( elem, o.mode || "show" ), + show = mode === "show", + hide = mode === "hide", + showhide = ( show || mode === "hide" ), - // showing or hiding leaves of the "last" animation - anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ), - duration = o.duration / anims, - animateTo = 0, - queue = elem.queue(), - queuelen = queue.length, - i; + // showing or hiding leaves of the "last" animation + anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ), + duration = o.duration / anims, + animateTo = 0, + queue = elem.queue(), + queuelen = queue.length, + i; - if ( show || !elem.is(':visible')) { - elem.css( "opacity", 0 ).show(); - animateTo = 1; - } - - // anims - 1 opacity "toggles" - for ( i = 1; i < anims; i++ ) { - elem.animate({ - opacity: animateTo - }, duration, o.easing ); - animateTo = 1 - animateTo; - } + if ( show || !elem.is(":visible")) { + elem.css( "opacity", 0 ).show(); + animateTo = 1; + } + // anims - 1 opacity "toggles" + for ( i = 1; i < anims; i++ ) { elem.animate({ opacity: animateTo - }, duration, o.easing); + }, duration, o.easing ); + animateTo = 1 - animateTo; + } - elem.queue( function( next ) { - if ( hide ) { - elem.hide(); - } - if ( o.complete ) { - o.complete.apply( this ); - } - next(); - }); + elem.animate({ + opacity: animateTo + }, duration, o.easing); - // We just queued up "anims" animations, we need to put them next in the queue - if ( queuelen > 1) { - queue.splice.apply( queue, - [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); + elem.queue( function( next ) { + if ( hide ) { + elem.hide(); + } + if ( o.complete ) { + o.complete.apply( this ); } next(); }); + + // We just queued up "anims" animations, we need to put them next in the queue + if ( queuelen > 1 ) { + queue.splice.apply( queue, + [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); + } + next(); }; })(jQuery); |