Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 46662d3

Browse files
crisbetoThomasBurleson
authored andcommitted
fix(tooltip): prevent element occasionally animating in from the top
* Fixes the tooltip some times flying in from the top on the first enter. * Fixes tooltips sometimes flying in from the top when switching quickly between elements that have tooltips. Fixes #8818. Closes #9117
1 parent fbe7957 commit 46662d3

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/components/tooltip/tooltip.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function MdTooltipDirective($timeout, $window, $$rAF, $document, $mdUtil, $mdThe
3838

3939
var ENTER_EVENTS = 'focus touchstart mouseenter';
4040
var LEAVE_EVENTS = 'blur touchcancel mouseleave';
41+
var SHOW_CLASS = 'md-show';
4142
var TOOLTIP_SHOW_DELAY = 0;
4243
var TOOLTIP_WINDOW_EDGE_SPACE = 8;
4344

@@ -320,23 +321,16 @@ function MdTooltipDirective($timeout, $window, $$rAF, $document, $mdUtil, $mdThe
320321

321322
updatePosition();
322323

323-
angular.forEach([element, content], function (element) {
324-
$animate.addClass(element, 'md-show');
324+
$animate.addClass(content, SHOW_CLASS).then(function() {
325+
element.addClass(SHOW_CLASS);
325326
});
326327
}
327328

328329
function hideTooltip() {
329-
var promises = [];
330-
angular.forEach([element, content], function (it) {
331-
if (it.parent() && it.hasClass('md-show')) {
332-
promises.push($animate.removeClass(it, 'md-show'));
333-
}
334-
});
335-
336-
$q.all(promises)
337-
.then(function () {
338-
if (!scope.visible) element.detach();
339-
});
330+
$animate.removeClass(content, SHOW_CLASS).then(function(){
331+
element.removeClass(SHOW_CLASS);
332+
if (!scope.visible) element.detach();
333+
});
340334
}
341335

342336
function updatePosition() {

0 commit comments

Comments
 (0)