Skip to content

Commit e530d06

Browse files
committed
Tooltip: Pass the tooltip element in the open and close events.
1 parent 1b52cef commit e530d06

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

demos/tooltip/custom-animation.html

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,14 @@
2626
delay: 250
2727
}
2828
});
29-
$( "#position-option" ).tooltip({
29+
$( "#open-event" ).tooltip({
30+
show: null,
3031
position: {
3132
my: "left top",
32-
at: "left bottom+10",
33-
using: function( pos ) {
34-
$( this ).css({
35-
left: pos.left,
36-
top: pos.top - 10
37-
}).animate({ top: pos.top }, "fast" );
38-
}
33+
at: "left bottom"
34+
},
35+
open: function( event, ui ) {
36+
ui.tooltip.animate({ top: ui.tooltip.position().top + 10 }, "fast" );
3937
}
4038
});
4139
});
@@ -48,16 +46,15 @@
4846
<p>There are various ways to customize the animation of a tooltip.</p>
4947
<p>You can use the <a id="show-option" href="http://jqueryui.com/demos/tooltip/#option-show" title="slide down on show">show</a> and
5048
<a id="hide-option" href="http://jqueryui.com/demos/tooltip/#option-hide" title="explode on hide">hide</a> options.</p>
51-
<p>You can also use the <a id="position-option" href="http://jqueryui.com/demos/tooltip/#option-position" title="move down on show">position option</a>.</p>
49+
<p>You can also use the <a id="open-event" href="http://jqueryui.com/demos/tooltip/#event-open" title="move down on show">open event</a>.</p>
5250

5351
</div><!-- End demo -->
5452

5553

5654

5755
<div class="demo-description">
58-
<p>This demo shows how to customize animations. The tooltip is shown, after a
59-
delay of 250ms, using a slide down animation, and hidden, after another delay,
60-
without an animation.</p>
56+
<p>This demo shows how to customize animations using the show and hide options,
57+
as well as the open event.</p>
6158
</div><!-- End demo-description -->
6259

6360
</body>

ui/jquery.ui.tooltip.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,13 @@ $.widget( "ui.tooltip", {
138138
tooltip
139139
.stop( true )
140140
.position( $.extend({
141-
of: target,
142-
using: function( pos ) {
143-
// we only want to hide if there's no custom using defined
144-
$( this ).css( pos ).hide();
145-
}
146-
}, this.options.position ) );
141+
of: target
142+
}, this.options.position ) )
143+
.hide();
147144

148145
this._show( tooltip, this.options.show );
149146

150-
this._trigger( "open", event );
147+
this._trigger( "open", event, { tooltip: tooltip } );
151148

152149
this._bind( target, {
153150
mouseleave: "close",
@@ -181,7 +178,7 @@ $.widget( "ui.tooltip", {
181178

182179
target.unbind( "mouseleave.tooltip blur.tooltip" );
183180

184-
this._trigger( "close", event );
181+
this._trigger( "close", event, { tooltip: tooltip } );
185182
},
186183

187184
_tooltip: function( element ) {

0 commit comments

Comments
 (0)