]> source.dussan.org Git - jquery-ui.git/commitdiff
Tooltip: Overhaul widget animations code to allow delay with plain show/hide
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Mon, 2 May 2011 11:11:58 +0000 (13:11 +0200)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Mon, 2 May 2011 11:11:58 +0000 (13:11 +0200)
demos/tooltip/custom-animation.html
ui/jquery.ui.widget.js

index d0689a0ebf5f25c7a54d6ad907cd8546d4ad9156..ef885797977ef34b8836ab7e7e41a42cfb5d1dde 100644 (file)
@@ -17,8 +17,8 @@
                                delay: 250
                        },
                        hide: {
-                               effect: "slideUp",
-                               delay: 500
+                               effect: "hide",
+                               delay: 250
                        }
                });
        });
@@ -47,7 +47,9 @@
 
 <div class="demo-description">
 
-<p>Here the tooltips are positioned relative to the mouse, and follow the mouse while it moves above the element.</p>
+<p>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.</p>
 
 </div><!-- End demo-description -->
 
index 9634eaa1fcaf58328c5e489d19357999b547a53a..a5c59ad3c16576651ae26a7c730b96fc22b9df5e 100644 (file)
@@ -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 ] );
+                               }
+                       });
                }
        };
 });