|
|
|
@ -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("<div>").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 { |
|
|
|
|