Skip to content
Permalink
Browse files
Tooltip show / hide animation effects
http://wiki.jqueryui.com/w/page/12138112/Tooltip
http://bugs.jqueryui.com/ticket/3772

Fixed: #3772 - work through places where animations could be used

this time solution based on both my previous pull requests:

 - added new method to tooltip object "_animate", that is based on kbwood animation solution posted http://bugs.jqueryui.com/ticket/3772#comment:6

 - default animations fadeIn / fadeOut implemented, thank's Jörn)

 - And some from Jörn:
 "Somewhat related: With this API implemented,
	the close callback could run once the animation is completed,
	instead of as soon as the animation starts.
	Though that could get into trouble
	when the closing animation is cancelled (hover before animation finished)."

	So may be fire trigger close event just before animation fired?
  • Loading branch information
dmitryevseev committed Feb 16, 2011
1 parent c94ec23 commit 3420184
Showing 1 changed file with 32 additions and 3 deletions.
@@ -86,7 +86,27 @@ $.widget("ui.tooltip", {
self._show(event, target, content);
}
},


/**
* used function from this comment http://bugs.jqueryui.com/ticket/3772#comment:6
*/
_animate: function (effect, showing) {
// Convert to array
effect = ($.isArray(effect) ? effect : (typeof effect === 'string' ? [effect] :
[effect.fx, effect.options, effect.speed, effect.callback]));
// Check for options
(effect[1] && typeof effect[1] !== 'object' ? effect.splice(1, 0, null) : effect);
// Check for callback
($.isFunction(effect[2]) ? effect.splice(2, 0, null) : effect);
// Special case for 'show'
effect = (effect[0] && effect[0] !== 'show' ? effect : effect.slice(2));
(effect[0] === 'fade' ?
// Special case for 'fade'
this.tooltip[showing ? 'fadeIn' : 'fadeOut'].apply(this.tooltip, effect.slice(2)) :
// Apply effect
this.tooltip[showing ? 'show' : 'hide'].apply(this.tooltip, effect));
},

_show: function(event, target, content) {
if (!content)
return;
@@ -107,7 +127,11 @@ $.widget("ui.tooltip", {
this.tooltip.attr("aria-hidden", "false");
target.attr("aria-describedby", this.tooltip.attr("id"));

this.tooltip.stop(false, true).fadeIn();
//move animation code apart, so will be no need to repeat stop in "if" closures
this.tooltip.stop(false, true);

//if show was not provided -> trigger default fadeIn animation
this._animate( !this.options.show ? 'fade' : this.options.show, 1 );

this._trigger( "open", event );
},
@@ -126,9 +150,14 @@ $.widget("ui.tooltip", {
current.removeAttr("aria-describedby");
this.tooltip.attr("aria-hidden", "true");

this.tooltip.stop(false, true).fadeOut();
//move animation code apart, so will be no need to repeat stop in "if" closures
this.tooltip.stop(false, true);

//trigger close event just before animation fired?
this._trigger( "close", event );

//show was not provided -> trigger default fadeIn animation
this._animate( !this.options.hide ? 'fade' : this.options.hide, 0 );
}
});

0 comments on commit 3420184

Please sign in to comment.