pull/4003/head
zcyzcy88 2017-04-05 02:29:37 +08:00 committed by 杨奕
parent 658a91ee23
commit d0be75a467
1 changed files with 10 additions and 2 deletions

View File

@ -517,9 +517,17 @@
var scrollParent = getScrollParent(this._popper);
var offsetParentRect = getOffsetRect(offsetParent);
// Thanks the fucking native API, `document.body.scrollTop` & `document.documentElement.scrollTop`
var getScrollTopValue = function (element) {
return element == document.body ? Math.max(document.documentElement.scrollTop, document.body.scrollTop) : element.scrollTop;
}
var getScrollLeftValue = function (element) {
return element == document.body ? Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) : element.scrollLeft;
}
// if the popper is fixed we don't have to substract scrolling from the boundaries
var scrollTop = data.offsets.popper.position === 'fixed' ? 0 : scrollParent.scrollTop;
var scrollLeft = data.offsets.popper.position === 'fixed' ? 0 : scrollParent.scrollLeft;
var scrollTop = data.offsets.popper.position === 'fixed' ? 0 : getScrollTopValue(scrollParent);
var scrollLeft = data.offsets.popper.position === 'fixed' ? 0 : getScrollLeftValue(scrollParent);
boundaries = {
top: 0 - (offsetParentRect.top - scrollTop),