From: Jörn Zaefferer Date: Mon, 2 May 2011 11:11:58 +0000 (+0200) Subject: Tooltip: Overhaul widget animations code to allow delay with plain show/hide X-Git-Tag: 1.9m5~121 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a03c222f05aa2364189d264377e0a19da4d4c9ad;p=jquery-ui.git Tooltip: Overhaul widget animations code to allow delay with plain show/hide --- diff --git a/demos/tooltip/custom-animation.html b/demos/tooltip/custom-animation.html index d0689a0eb..ef8857979 100644 --- a/demos/tooltip/custom-animation.html +++ b/demos/tooltip/custom-animation.html @@ -17,8 +17,8 @@ delay: 250 }, hide: { - effect: "slideUp", - delay: 500 + effect: "hide", + delay: 250 } }); }); @@ -47,7 +47,9 @@
-

Here the tooltips are positioned relative to the mouse, and follow the mouse while it moves above the element.

+

This demo shows how to customize animations. The tooltip is shown, after a +delay of 250ms, using a slide down animation, and hidden, after another delay, +without an animation.

diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 9634eaa1f..a5c59ad3c 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -365,12 +365,23 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { if ( hasOptions && $.effects && $.effects[ effectName ] ) { element[ method ]( options ); } else if ( element[ effectName ] ) { - element[ effectName ]( options.duration, options.easing, callback ); - } else { - element[ method ](); - if ( callback ) { - callback.call( element[ 0 ] ); + if ( /show|hide/.test( effectName ) ) { + element.queue( function() { + element[ effectName ](); + if ( callback ) { + callback.call( element[ 0 ] ); + } + }); + } else { + element[ effectName ]( options.duration, options.easing, callback ); } + } else { + element.queue( function() { + $( this )[ method ](); + if ( callback ) { + callback.call( element[ 0 ] ); + } + }); } }; });