Skip to content

Commit

Permalink
added setTimeout fix for manual popover placement
Browse files Browse the repository at this point in the history
  • Loading branch information
evillemez committed Aug 24, 2015
1 parent a5e6518 commit 06d56c3
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 44 deletions.
38 changes: 20 additions & 18 deletions dist/angular-strap.js
Expand Up @@ -3603,26 +3603,28 @@
$tooltip.$isShown = scope.$isShown = true;
safeDigest(scope);
$tooltip.$applyPlacement();
if (angular.version.minor <= 2) {
$animate.enter(tipElement, parent, after, enterAnimateCallback);
} else {
$animate.enter(tipElement, parent, after).then(enterAnimateCallback);
}
safeDigest(scope);
$$rAF(function() {
if (tipElement) tipElement.css({
visibility: 'visible'
$window.setTimeout(function() {
if (angular.version.minor <= 2) {
$animate.enter(tipElement, parent, after, enterAnimateCallback);
} else {
$animate.enter(tipElement, parent, after).then(enterAnimateCallback);
}
safeDigest(scope);
$$rAF(function() {
if (tipElement) tipElement.css({
visibility: 'visible'
});
});
});
if (options.keyboard) {
if (options.trigger !== 'focus') {
$tooltip.focus();
if (options.keyboard) {
if (options.trigger !== 'focus') {
$tooltip.focus();
}
bindKeyboardEvents();
}
bindKeyboardEvents();
}
if (options.autoClose) {
bindAutoCloseEvents();
}
if (options.autoClose) {
bindAutoCloseEvents();
}
}, 0);
};
function enterAnimateCallback() {
scope.$emit(options.prefixEvent + '.show', $tooltip);
Expand Down
59 changes: 33 additions & 26 deletions src/tooltip/tooltip.js
Expand Up @@ -206,36 +206,43 @@ angular.module('mgcrea.ngStrap.tooltip', ['mgcrea.ngStrap.core', 'mgcrea.ngStrap

$tooltip.$isShown = scope.$isShown = true;
safeDigest(scope);

// Copied from drew-r:
// https://github.com/drew-r/angular-strap/commit/07a57497c588b550d960a64f9fd92714d4c00c79
//
// Timeout applies position after content has been properly parsed, fixing positioning
// with manual trigger
$window.setTimeout(function() {
// Now, apply placement
$tooltip.$applyPlacement();

// Once placed, animate it.
// Support v1.2+ $animate
// https://github.com/angular/angular.js/issues/11713
if(angular.version.minor <= 2) {
$animate.enter(tipElement, parent, after, enterAnimateCallback);
} else {
$animate.enter(tipElement, parent, after).then(enterAnimateCallback);
}
safeDigest(scope);

// Now, apply placement
$tooltip.$applyPlacement();

// Once placed, animate it.
// Support v1.2+ $animate
// https://github.com/angular/angular.js/issues/11713
if(angular.version.minor <= 2) {
$animate.enter(tipElement, parent, after, enterAnimateCallback);
} else {
$animate.enter(tipElement, parent, after).then(enterAnimateCallback);
}
safeDigest(scope);

$$rAF(function () {
// Once the tooltip is placed and the animation starts, make the tooltip visible
if(tipElement) tipElement.css({visibility: 'visible'});
});
$$rAF(function () {
// Once the tooltip is placed and the animation starts, make the tooltip visible
if(tipElement) tipElement.css({visibility: 'visible'});
});

// Bind events
if(options.keyboard) {
if(options.trigger !== 'focus') {
$tooltip.focus();
// Bind events
if(options.keyboard) {
if(options.trigger !== 'focus') {
$tooltip.focus();
}
bindKeyboardEvents();
}
bindKeyboardEvents();
}

if(options.autoClose) {
bindAutoCloseEvents();
}
if(options.autoClose) {
bindAutoCloseEvents();
}
}, 0);

};

Expand Down

0 comments on commit 06d56c3

Please sign in to comment.