From 9bf65c63211f8c1efe84d4693c71b528f79c7e61 Mon Sep 17 00:00:00 2001 From: fay Date: Wed, 13 May 2020 14:30:38 +0800 Subject: [PATCH] =?UTF-8?q?BI-65305=20fix:=20popup=E6=96=B9=E5=90=91?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E5=9C=A8scale=E5=BD=B1=E5=93=8D=E4=B8=8B?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/web/plugin.screen_adaptive.js | 20 ++++++++++++------- .../com/finebi/plugin/web/scripts/entry.js | 20 ++++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js b/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js index eca5b69..8b154ff 100644 --- a/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js +++ b/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js @@ -191,8 +191,8 @@ offsetTop = 0; do{ - offsetLeft += el.offsetLeft; - offsetTop += el.offsetTop; + offsetLeft += ( BI.isIE() ? window.getComputedStyle(el).position === "fixed" ? el.offsetLeft / scale : el.offsetLeft : el.offsetLeft ); + offsetTop += ( BI.isIE() ? window.getComputedStyle(el).position === "fixed" ? el.offsetTop / scale : el.offsetTop : el.offsetTop ); el = el.offsetParent; } while( el ); @@ -231,12 +231,16 @@ } else { var cBounds = this.popupView.element[0].getBoundingClientRect(); var pBounds = this.popupView.element[0].parentElement.getBoundingClientRect(); - if (parseInt(cBounds.top) >= parseInt(pBounds.top) && parseInt(cBounds.left) >= parseInt(pBounds.left)) { + if (cBounds.left + cBounds.width > body.clientWidth * scale) { + this.popupView.element[0].style.top = (parseInt(pBounds.top) + transformY - document.body.scrollTop) + "px"; + this.popupView.element[0].style.left = (parseInt(this.popupView.element[0].style.left) * scale) + "px"; + } else if (this.options.direction === "right") { + this.popupView.element[0].style.top = (parseInt(pBounds.top) + transformY - document.body.scrollTop) + "px"; + this.popupView.element[0].style.left = (parseInt(pBounds.right) + transformY - document.body.scrollTop) + "px"; + } else if (parseInt(cBounds.top) >= parseInt(pBounds.top) && parseInt(cBounds.left) >= parseInt(pBounds.left)) { this.popupView.element[0].style.top = (parseInt(pBounds.bottom) + transformY - document.body.scrollTop) + "px"; this.popupView.element[0].style.left = (parseInt(pBounds.left) + transformY - document.body.scrollTop) + "px"; - } - - if (parseInt(cBounds.top) >= parseInt(pBounds.top) && parseInt(cBounds.left) < parseInt(pBounds.left)) { + }else if (parseInt(cBounds.top) >= parseInt(pBounds.top) && parseInt(cBounds.left) < parseInt(pBounds.left)) { this.popupView.element[0].style.top = (parseInt(pBounds.bottom) + transformY - document.body.scrollTop) + "px"; this.popupView.element[0].style.left = (parseInt(pBounds.left) + transformY - document.body.scrollTop) + "px"; } @@ -275,7 +279,9 @@ injectSearch.call(this); var self = this; if (this.popupView) { - BI.nextTick(function () { + BI.defer(function () { + self.popupView.element[0].parentElement.style.left = parseInt(self.popupView.element[0].parentElement.style.left) * scale + "px"; + self.popupView.element[0].parentElement.style.top = parseInt(self.popupView.element[0].parentElement.style.top) * scale + "px"; self.popupView.element[0].parentElement.style.transform = "scale(" + scale + ")"; self.popupView.element[0].parentElement.style.transformOrigin = "left top"; }) diff --git a/src/main/resources/com/finebi/plugin/web/scripts/entry.js b/src/main/resources/com/finebi/plugin/web/scripts/entry.js index eca5b69..8b154ff 100644 --- a/src/main/resources/com/finebi/plugin/web/scripts/entry.js +++ b/src/main/resources/com/finebi/plugin/web/scripts/entry.js @@ -191,8 +191,8 @@ offsetTop = 0; do{ - offsetLeft += el.offsetLeft; - offsetTop += el.offsetTop; + offsetLeft += ( BI.isIE() ? window.getComputedStyle(el).position === "fixed" ? el.offsetLeft / scale : el.offsetLeft : el.offsetLeft ); + offsetTop += ( BI.isIE() ? window.getComputedStyle(el).position === "fixed" ? el.offsetTop / scale : el.offsetTop : el.offsetTop ); el = el.offsetParent; } while( el ); @@ -231,12 +231,16 @@ } else { var cBounds = this.popupView.element[0].getBoundingClientRect(); var pBounds = this.popupView.element[0].parentElement.getBoundingClientRect(); - if (parseInt(cBounds.top) >= parseInt(pBounds.top) && parseInt(cBounds.left) >= parseInt(pBounds.left)) { + if (cBounds.left + cBounds.width > body.clientWidth * scale) { + this.popupView.element[0].style.top = (parseInt(pBounds.top) + transformY - document.body.scrollTop) + "px"; + this.popupView.element[0].style.left = (parseInt(this.popupView.element[0].style.left) * scale) + "px"; + } else if (this.options.direction === "right") { + this.popupView.element[0].style.top = (parseInt(pBounds.top) + transformY - document.body.scrollTop) + "px"; + this.popupView.element[0].style.left = (parseInt(pBounds.right) + transformY - document.body.scrollTop) + "px"; + } else if (parseInt(cBounds.top) >= parseInt(pBounds.top) && parseInt(cBounds.left) >= parseInt(pBounds.left)) { this.popupView.element[0].style.top = (parseInt(pBounds.bottom) + transformY - document.body.scrollTop) + "px"; this.popupView.element[0].style.left = (parseInt(pBounds.left) + transformY - document.body.scrollTop) + "px"; - } - - if (parseInt(cBounds.top) >= parseInt(pBounds.top) && parseInt(cBounds.left) < parseInt(pBounds.left)) { + }else if (parseInt(cBounds.top) >= parseInt(pBounds.top) && parseInt(cBounds.left) < parseInt(pBounds.left)) { this.popupView.element[0].style.top = (parseInt(pBounds.bottom) + transformY - document.body.scrollTop) + "px"; this.popupView.element[0].style.left = (parseInt(pBounds.left) + transformY - document.body.scrollTop) + "px"; } @@ -275,7 +279,9 @@ injectSearch.call(this); var self = this; if (this.popupView) { - BI.nextTick(function () { + BI.defer(function () { + self.popupView.element[0].parentElement.style.left = parseInt(self.popupView.element[0].parentElement.style.left) * scale + "px"; + self.popupView.element[0].parentElement.style.top = parseInt(self.popupView.element[0].parentElement.style.top) * scale + "px"; self.popupView.element[0].parentElement.style.transform = "scale(" + scale + ")"; self.popupView.element[0].parentElement.style.transformOrigin = "left top"; })