From a5f50bedaf566956e54e04d9cad219917b00b6b8 Mon Sep 17 00:00:00 2001 From: zsmj Date: Wed, 12 Apr 2023 15:12:27 +0800 Subject: [PATCH] =?UTF-8?q?BI-124559=20fix:=20=E5=8D=87=E7=BA=A7BI6?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=90=8E=EF=BC=8C=E8=80=81=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E7=81=AB=E7=8B=90=E6=B5=8F=E8=A7=88=E5=99=A8=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=89=93=E5=BC=80=E4=BB=AA=E8=A1=A8=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 支持传入额外属性 --- src/core/platform/web/dom.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/core/platform/web/dom.js b/src/core/platform/web/dom.js index ffb005985..0c190cb2f 100644 --- a/src/core/platform/web/dom.js +++ b/src/core/platform/web/dom.js @@ -108,12 +108,13 @@ }, // 获取滚动条的宽度,页面display: none时候获取到的为0 - getScrollWidth: function () { + getScrollWidth: function (css) { if (BI.isNull(this._scrollWidth) || this._scrollWidth === 0) { var ul = BI.Widget._renderEngine.createElement("
").width(50).height(50).css({ position: "absolute", top: "-9999px", - overflow: "scroll" + overflow: "scroll", + ...css }).appendTo("body"); this._scrollWidth = ul[0].offsetWidth - ul[0].clientWidth; ul.destroy(); @@ -156,7 +157,7 @@ var popupEl = popup.element; var elRect = el[0].getBoundingClientRect(); var popupElRect = popupEl[0].getBoundingClientRect(); - var containerRect = container ? container.getBoundingClientRect() : { left: 0 }; + var containerRect = container ? container.getBoundingClientRect() : {left: 0}; return { left: elRect.left - containerRect.left - popupElRect.width - (extraWidth || 0) @@ -172,7 +173,7 @@ getRightPosition: function (combo, popup, extraWidth, container) { var el = combo.element; var elRect = el[0].getBoundingClientRect(); - var containerRect = container ? container.getBoundingClientRect() : { left: 0 }; + var containerRect = container ? container.getBoundingClientRect() : {left: 0}; return { left: elRect.left + elRect.width - containerRect.left + (extraWidth || 0) @@ -191,7 +192,7 @@ var popupEl = popup.element; var elRect = el[0].getBoundingClientRect(); var popupElRect = popupEl[0].getBoundingClientRect(); - var containerRect = container ? container.getBoundingClientRect() : { top: 0 }; + var containerRect = container ? container.getBoundingClientRect() : {top: 0}; return { top: elRect.top - containerRect.top - popupElRect.height - (extraHeight || 0) @@ -201,7 +202,7 @@ getBottomPosition: function (combo, popup, extraHeight, container) { var el = combo.element; var elRect = el[0].getBoundingClientRect(); - var containerRect = container ? container.getBoundingClientRect() : { top: 0 }; + var containerRect = container ? container.getBoundingClientRect() : {top: 0}; return { top: elRect.top - containerRect.top + elRect.height + (extraHeight || 0) @@ -254,7 +255,7 @@ var comboRect = combo.element[0].getBoundingClientRect(), popupRect = popup.element[0].getBoundingClientRect(), viewportRect = document.documentElement.getBoundingClientRect(), - containerRect = container ? container.getBoundingClientRect() : { left: 0 }; + containerRect = container ? container.getBoundingClientRect() : {left: 0}; var left = comboRect.left - containerRect.left + extraWidth; if (comboRect.left + popupRect.width > viewportRect.width) { @@ -267,7 +268,7 @@ var left = this._getLeftAlignPosition(combo, popup, extraWidth, container); var dir = ""; // 如果放不下,优先使用RightAlign, 如果RightAlign也放不下, 再使用left=0 - var containerRect = container ? container.getBoundingClientRect() : { left: 0 }; + var containerRect = container ? container.getBoundingClientRect() : {left: 0}; if (left + containerRect.left < 0) { left = this._getRightAlignPosition(combo, popup, extraWidth); dir = "left"; @@ -293,7 +294,7 @@ _getRightAlignPosition: function (combo, popup, extraWidth, container) { var comboBounds = combo.element[0].getBoundingClientRect(), viewBounds = popup.element[0].getBoundingClientRect(), - containerRect = container ? container.getBoundingClientRect() : { left: 0 }; + containerRect = container ? container.getBoundingClientRect() : {left: 0}; return comboBounds.left + comboBounds.width - viewBounds.width - extraWidth - containerRect.left; }, @@ -327,7 +328,7 @@ var comboBounds = combo.element[0].getBoundingClientRect(), popupBounds = popup.element[0].getBoundingClientRect(), viewportBounds = document.documentElement.getBoundingClientRect(), - containerBounds = container ? container.getBoundingClientRect() : { top: 0 }; + containerBounds = container ? container.getBoundingClientRect() : {top: 0}; var top, adaptHeight, dir; if (BI.DOM.isBottomSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) { top = comboBounds.top - containerBounds.top + extraHeight; @@ -386,7 +387,7 @@ var comboBounds = combo.element[0].getBoundingClientRect(), popupBounds = popup.element[0].getBoundingClientRect(), windowBounds = BI.Widget._renderEngine.createElement("body").bounds(), - containerBounds = container ? container.getBoundingClientRect() : { top: 0 }; + containerBounds = container ? container.getBoundingClientRect() : {top: 0}; var top, adaptHeight, dir; if (BI.DOM.isTopSpaceEnough(combo, popup, -1 * comboBounds.height + extraHeight)) { top = comboBounds.top + comboBounds.height - containerBounds.top - popupBounds.height; @@ -746,7 +747,7 @@ */ getPositionRelativeContainingBlockRect: function (element) { const positionRelativeElement = BI.DOM.getPositionRelativeContainingBlock(element); - const { top, right, bottom, left, width, height, x, y } = positionRelativeElement.getBoundingClientRect(); + const {top, right, bottom, left, width, height, x, y} = positionRelativeElement.getBoundingClientRect(); return {