Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(tooltip): correctly position tooltip
Browse files Browse the repository at this point in the history
- Use a style reset so the DOM recalculates values before correctly positioning the tooltip

Closes #4311
Fixes #4195
  • Loading branch information
dabos-GFI authored and wesleycho committed Aug 31, 2015
1 parent b1e98b1 commit 457f10c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,20 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.b

var positionTooltip = function() {
if (!tooltip) { return; }

var ttPosition = $position.positionElements(element, tooltip, ttScope.placement, appendToBody);
ttPosition.top += 'px';
ttPosition.left += 'px';

// Now set the calculated positioning.
tooltip.css(ttPosition);

// Reset the positioning and box size for correct width and height values.
tooltip.css({ top: 0, left: 0, width: 'auto', height: 'auto' });

var ttBox = $position.position(tooltip);
var ttCss = $position.positionElements(element, tooltip, ttScope.placement, appendToBody);
ttCss.top += 'px';
ttCss.left += 'px';

ttCss.width = ttBox.width + 'px';
ttCss.height = ttBox.height + 'px';

// Now set the calculated positioning and size.
tooltip.css(ttCss);
};

var positionTooltipAsync = function() {
Expand Down

0 comments on commit 457f10c

Please sign in to comment.