You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 29, 2019. It is now read-only.
I'm using the tooltip component in an AngularJS application. The initial configuration was the default (tooltip-append-to-body=false).
Then, I noticed that my tooltip is misplaced when I scrolled down the window in Chrome. After some debugging, I realized that the closest ancestor which has a explicit position (offsetParent) was the "body" element. This element seems to be a bit special, because (at least in Chrome), is the only one for which both "scrollTop" and $window.pageYOffset properties get updated. For any other element, we will have pageYOffset updated when we scroll the window, and scrollTop, when we scroll the element (if made scrollable with overflow: scroll).
Should I set "tooltip-append-to-body" directive to true when the body is the offsetParent? If so, I had another issue: If the body is positioned "relative" with top/left different to 0, the tooltip will be misplaced by that same amount. The reason lies here:
var positionTooltip = function (){
// Get the position of the directive element.
position = appendToBody ? $position.offset( element ) : $position.position( element );
}
The offset of the element is calculated from the top-left coordinates of the document, not necessarily the body (which can be offset relatively, as explained above).
If this is the intended way the code should work, I think the documentation (http://angular-ui.github.io/bootstrap/) should be updated to make the API a bit clearer, because the only way for me to understand this was debugging the code.
Thanks,
Aritz
The text was updated successfully, but these errors were encountered:
Well, to be honest, I have no idea about positioning, not my topic. Now, if the current implementation is OK but there is a behavior that is not documented, absolutely yes.
I'm using the tooltip component in an AngularJS application. The initial configuration was the default (tooltip-append-to-body=false).
Then, I noticed that my tooltip is misplaced when I scrolled down the window in Chrome. After some debugging, I realized that the closest ancestor which has a explicit position (offsetParent) was the "body" element. This element seems to be a bit special, because (at least in Chrome), is the only one for which both "scrollTop" and $window.pageYOffset properties get updated. For any other element, we will have pageYOffset updated when we scroll the window, and scrollTop, when we scroll the element (if made scrollable with overflow: scroll).
As a result, the geometry arithmetic in position() function will not work with the "body" element:
https://github.com/angular-ui/bootstrap/blob/master/src/position/position.js#L47
Should I set "tooltip-append-to-body" directive to true when the body is the offsetParent? If so, I had another issue: If the body is positioned "relative" with top/left different to 0, the tooltip will be misplaced by that same amount. The reason lies here:
var positionTooltip = function (){
// Get the position of the directive element.
position = appendToBody ? $position.offset( element ) : $position.position( element );
}
The offset of the element is calculated from the top-left coordinates of the document, not necessarily the body (which can be offset relatively, as explained above).
If this is the intended way the code should work, I think the documentation (http://angular-ui.github.io/bootstrap/) should be updated to make the API a bit clearer, because the only way for me to understand this was debugging the code.
Thanks,
Aritz
The text was updated successfully, but these errors were encountered: