From 3e65123596f2fe9dbfcbb2f2d8d3fe11cc9fa87c Mon Sep 17 00:00:00 2001 From: zsmj Date: Wed, 14 Dec 2022 10:05:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?KERNEL-11877=20fix:=20supportCSSTransform?= =?UTF-8?q?=20=E9=BB=98=E8=AE=A4=E6=94=B9=E4=B8=BAtrue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/combination/combo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index c937f8f84..ee1f30a1f 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -38,7 +38,7 @@ adjustLength: 0, // 调整的距离 adjustXOffset: 0, adjustYOffset: 0, - supportCSSTransform: false, + supportCSSTransform: true, hideChecker: BI.emptyFn, offsetStyle: "left", // left,right,center el: {}, From 062f80437c9e7ac3fa12aef74f20098c6d643e7e Mon Sep 17 00:00:00 2001 From: zsmj Date: Wed, 14 Dec 2022 11:13:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?BI-118849=20fix:=20=E9=80=82=E9=85=8D=20off?= =?UTF-8?q?setStyle=20center=E5=92=8Cmiddle=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/combination/combo.js | 8 +++---- src/core/platform/web/dom.js | 43 +++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index ee1f30a1f..f73fec11d 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -40,7 +40,7 @@ adjustYOffset: 0, supportCSSTransform: true, hideChecker: BI.emptyFn, - offsetStyle: "left", // left,right,center + offsetStyle: "", // "",center,middle el: {}, popup: {}, comboClass: "bi-combo-popup", @@ -308,10 +308,10 @@ var scaleX = positonedRect.width / positionRelativeElement.offsetWidth; var scaleY = positonedRect.height / positionRelativeElement.offsetHeight; - p.top && (p.top = p.top / scaleY); - p.left && (p.left = p.left / scaleX); + p.top && (p.top = Math.round(p.top / scaleY)); + p.left && (p.left = Math.round(p.left / scaleX)); - p.adaptHeight && (p.adaptHeight = p.adaptHeight / scaleY); + p.adaptHeight && (p.adaptHeight = Math.round(p.adaptHeight / scaleY)); } if ("adaptHeight" in p) { diff --git a/src/core/platform/web/dom.js b/src/core/platform/web/dom.js index 17dd9d479..203683297 100644 --- a/src/core/platform/web/dom.js +++ b/src/core/platform/web/dom.js @@ -433,17 +433,18 @@ }; }, - getCenterAdaptPosition: function (combo, popup) { - var comboOffset = combo.element.offset(); - var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), - windowBounds = BI.Widget._renderEngine.createElement("body").bounds(); + getCenterAdaptPosition: function (combo, popup, positionRelativeElement) { + var comboRect = combo.element[0].getBoundingClientRect(), + popupRect = popup.element[0].getBoundingClientRect(), + positionRelativeElementRect = positionRelativeElement.getBoundingClientRect(), + viewportBounds = document.documentElement.getBoundingClientRect(); var left; - if (comboOffset.left + comboBounds.width / 2 + popupBounds.width / 2 > windowBounds.width) { - left = windowBounds.width - popupBounds.width; + if (comboRect.left + comboRect.width / 2 + popupRect.width / 2 > viewportBounds.width) { + left = viewportBounds.width - comboRect.width - positionRelativeElementRect.left; } else { - left = comboOffset.left + comboBounds.width / 2 - popupBounds.width / 2; + left = comboRect.left + (comboRect.width - popupRect.width) / 2 - positionRelativeElementRect.left; } - if (left < 0) { + if (left + positionRelativeElementRect.left < 0) { left = 0; } return { @@ -451,17 +452,19 @@ }; }, - getMiddleAdaptPosition: function (combo, popup) { - var comboOffset = combo.element.offset(); - var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), - windowBounds = BI.Widget._renderEngine.createElement("body").bounds(); + getMiddleAdaptPosition: function (combo, popup, positionRelativeElement) { + var comboRect = combo.element[0].getBoundingClientRect(), + popupRect = popup.element[0].getBoundingClientRect(), + positionRelativeElementRect = positionRelativeElement.getBoundingClientRect(), + viewportBounds = document.documentElement.getBoundingClientRect(); + var top; - if (comboOffset.top + comboBounds.height / 2 + popupBounds.height / 2 > windowBounds.height) { - top = windowBounds.height - popupBounds.height; + if (comboRect.top + comboRect.height / 2 + popupRect.height / 2 > viewportBounds.height) { + top = viewportBounds.height - popupRect.height - positionRelativeElementRect.top; } else { - top = comboOffset.top + comboBounds.height / 2 - popupBounds.height / 2; + top = comboRect.top + (comboRect.height - popupRect.height) / 2 - positionRelativeElementRect.top; } - if (top < 0) { + if (top + positionRelativeElementRect.top < 0) { top = 0; } return { @@ -681,19 +684,19 @@ switch (offsetStyle) { case "center": if (position.change) { - var p = BI.DOM.getMiddleAdaptPosition(combo, popup); + var p = BI.DOM.getMiddleAdaptPosition(combo, popup, positionRelativeElement); position.top = p.top; } else { - var p = BI.DOM.getCenterAdaptPosition(combo, popup); + var p = BI.DOM.getCenterAdaptPosition(combo, popup, positionRelativeElement); position.left = p.left; } break; case "middle": if (position.change) { - var p = BI.DOM.getCenterAdaptPosition(combo, popup); + var p = BI.DOM.getCenterAdaptPosition(combo, popup, positionRelativeElement); position.left = p.left; } else { - var p = BI.DOM.getMiddleAdaptPosition(combo, popup); + var p = BI.DOM.getMiddleAdaptPosition(combo, popup, positionRelativeElement); position.top = p.top; } break;