Skip to content

Commit a03c222

Browse files
committed
Tooltip: Overhaul widget animations code to allow delay with plain show/hide
1 parent 3bb9ab2 commit a03c222

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

demos/tooltip/custom-animation.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
delay: 250
1818
},
1919
hide: {
20-
effect: "slideUp",
21-
delay: 500
20+
effect: "hide",
21+
delay: 250
2222
}
2323
});
2424
});
@@ -47,7 +47,9 @@
4747

4848
<div class="demo-description">
4949

50-
<p>Here the tooltips are positioned relative to the mouse, and follow the mouse while it moves above the element.</p>
50+
<p>This demo shows how to customize animations. The tooltip is shown, after a
51+
delay of 250ms, using a slide down animation, and hidden, after another delay,
52+
without an animation.</p>
5153

5254
</div><!-- End demo-description -->
5355

ui/jquery.ui.widget.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,23 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
365365
if ( hasOptions && $.effects && $.effects[ effectName ] ) {
366366
element[ method ]( options );
367367
} else if ( element[ effectName ] ) {
368-
element[ effectName ]( options.duration, options.easing, callback );
369-
} else {
370-
element[ method ]();
371-
if ( callback ) {
372-
callback.call( element[ 0 ] );
368+
if ( /show|hide/.test( effectName ) ) {
369+
element.queue( function() {
370+
element[ effectName ]();
371+
if ( callback ) {
372+
callback.call( element[ 0 ] );
373+
}
374+
});
375+
} else {
376+
element[ effectName ]( options.duration, options.easing, callback );
373377
}
378+
} else {
379+
element.queue( function() {
380+
$( this )[ method ]();
381+
if ( callback ) {
382+
callback.call( element[ 0 ] );
383+
}
384+
});
374385
}
375386
};
376387
});

0 commit comments

Comments
 (0)