From 9fb37084c94885fa677f28c3d7259a99b544bf36 Mon Sep 17 00:00:00 2001 From: Justin Kahn Date: Fri, 21 Jun 2019 17:51:04 +0800 Subject: [PATCH 1/2] fix(Overlay): wrapper position absolute-close #812 --- src/overlay/main.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/overlay/main.scss b/src/overlay/main.scss index 03d243f226..17c1309419 100644 --- a/src/overlay/main.scss +++ b/src/overlay/main.scss @@ -1,6 +1,10 @@ @import "../core/index-noreset.scss"; .#{$css-prefix}overlay-wrapper { + position: absolute; + top: 0; + left: 0; + .#{$css-prefix}overlay-inner { z-index: 1001; } From 52ddf8da21935162e4e2985e5c0085be039420b9 Mon Sep 17 00:00:00 2001 From: Justin Kahn Date: Mon, 24 Jun 2019 11:54:57 +0800 Subject: [PATCH 2/2] fix(Overlay): comment out unnecessary code --- src/overlay/utils/position.js | 48 ++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/overlay/utils/position.js b/src/overlay/utils/position.js index db8c3df7c3..a10d54684c 100644 --- a/src/overlay/utils/position.js +++ b/src/overlay/utils/position.js @@ -191,27 +191,33 @@ export default class Position { } _makeElementInViewport(pinElement, number, type, isPinFixed) { - let result = number; - const docElement = document.documentElement; - const offsetParent = - pinElement.offsetParent || document.documentElement; - - if (result < 0) { - if (isPinFixed) { - result = 0; - } else if ( - offsetParent === document.body && - dom.getStyle(offsetParent, 'position') === 'static' - ) { - // Only when div's offsetParent is document.body, we set new position result. - result = Math.max( - docElement[`scroll${type}`], - document.body[`scroll${type}`] - ); - } - } - - return result; + // pinElement.offsetParent is never body because wrapper has position: absolute + // refactored to make code clearer. Revert if wrapper style changes. + + // let result = number; + // const docElement = document.documentElement; + // const offsetParent = + // pinElement.offsetParent || document.documentElement; + + // if (result < 0) { + // if (isPinFixed) { + // result = 0; + // } + + // else if ( + // offsetParent === document.body && + // dom.getStyle(offsetParent, 'position') === 'static' + // ) { + // // Only when div's offsetParent is document.body, we set new position result. + // result = Math.max( + // docElement[`scroll${type}`], + // document.body[`scroll${type}`] + // ); + // } + // } + // return result; + + return number < 0 && isPinFixed ? 0 : number; } _normalizePosition(element, align, isPinFixed) {