Skip to content

Commit

Permalink
Use getComputedStyle for height and width in IE to account for scroll…
Browse files Browse the repository at this point in the history
…bars
  • Loading branch information
jimevans committed Aug 8, 2019
1 parent 6a0b99a commit a0f2fa5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions javascript/atoms/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,23 @@ bot.dom.getOverflowState = function(elem, opt_region) {
return bot.dom.OverflowState.HIDDEN;
}

if (goog.userAgent.IE) {
// On IE, if the containing element has scroll bars, the
// height and width given by getComputedStyle differ from the
// client bounding rect. To avoid accidentally assuming the
// point is not overflowed, when it's really behind a scrollbar,
// use the effective height and width of the container.
var effectiveWidth = goog.string.parseInt(bot.dom.getEffectiveStyle(container, "width"));
var effectiveHeight = goog.string.parseInt(bot.dom.getEffectiveStyle(container, "height"));
if (effectiveWidth != containerRect.width ||
effectiveHeight != containerRect.height) {
containerRect = new goog.math.Rect(containerRect.left,
containerRect.top,
effectiveWidth,
effectiveHeight);
}
}

// Check "underflow": if an element is to the left or above the container
var underflowsX = region.right < containerRect.left;
var underflowsY = region.bottom < containerRect.top;
Expand Down

0 comments on commit a0f2fa5

Please sign in to comment.