diff --git a/src/core/platform/web/dom.js b/src/core/platform/web/dom.js index ef1989c8a..945aa359a 100644 --- a/src/core/platform/web/dom.js +++ b/src/core/platform/web/dom.js @@ -416,27 +416,28 @@ }; }, - getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) { + getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight, positionRelativeElement) { var comboBounds = combo.element[0].getBoundingClientRect(), popupBounds = popup.element[0].getBoundingClientRect(), - windowBounds = BI.Widget._renderEngine.createElement("body").bounds(); + viewportBounds = document.documentElement.getBoundingClientRect(), + positionRelativeElementRect = positionRelativeElement.getBoundingClientRect(); if (BI.DOM.isBottomSpaceEnough(combo, popup, extraHeight)) { - return BI.DOM.getBottomPosition(combo, popup, extraHeight); + return BI.DOM.getBottomPosition(combo, popup, extraHeight, positionRelativeElement); } if (needAdaptHeight) { return { - top: comboBounds.top + comboBounds.height + extraHeight, - adaptHeight: windowBounds.height - comboBounds.top - comboBounds.height - extraHeight + top: comboBounds.top + comboBounds.height + extraHeight - positionRelativeElementRect.top, + adaptHeight: viewportBounds.height - comboBounds.top - comboBounds.height - extraHeight }; } - if (popupBounds.height + extraHeight > windowBounds.height) { + if (popupBounds.height + extraHeight > viewportBounds.height) { return { - top: extraHeight, - adaptHeight: windowBounds.height - extraHeight + top: extraHeight - positionRelativeElementRect.top, + adaptHeight: viewportBounds.height - extraHeight }; } return { - top: windowBounds.height - popupBounds.height - extraHeight + top: viewportBounds.height - popupBounds.height - extraHeight - positionRelativeElementRect.top }; },