Skip to content

Commit a0f2fa5

Browse files
committed
Use getComputedStyle for height and width in IE to account for scrollbars
1 parent 6a0b99a commit a0f2fa5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

javascript/atoms/dom.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,23 @@ bot.dom.getOverflowState = function(elem, opt_region) {
740740
return bot.dom.OverflowState.HIDDEN;
741741
}
742742

743+
if (goog.userAgent.IE) {
744+
// On IE, if the containing element has scroll bars, the
745+
// height and width given by getComputedStyle differ from the
746+
// client bounding rect. To avoid accidentally assuming the
747+
// point is not overflowed, when it's really behind a scrollbar,
748+
// use the effective height and width of the container.
749+
var effectiveWidth = goog.string.parseInt(bot.dom.getEffectiveStyle(container, "width"));
750+
var effectiveHeight = goog.string.parseInt(bot.dom.getEffectiveStyle(container, "height"));
751+
if (effectiveWidth != containerRect.width ||
752+
effectiveHeight != containerRect.height) {
753+
containerRect = new goog.math.Rect(containerRect.left,
754+
containerRect.top,
755+
effectiveWidth,
756+
effectiveHeight);
757+
}
758+
}
759+
743760
// Check "underflow": if an element is to the left or above the container
744761
var underflowsX = region.right < containerRect.left;
745762
var underflowsY = region.bottom < containerRect.top;

0 commit comments

Comments
 (0)