Browse Source

Pull request #212094: Final/11.0

Merge in DEC/fineui from ~IMP/dec-fineui:final/11.0 to final/11.0

* commit '1e6724b56506ec95b8f5363951153f2e6ea21ee0':
  BI-119055 fix: needadaptive的下拉计算NaN
  auto upgrade version to 2.0.20221215171537
  BI-118849 fix: combo在屏幕边缘,左右位置不够之后的位置调整逻辑
  auto upgrade version to 2.0.20221215144622
  auto upgrade version to 2.0.20221215141039
research/test
imp-张健 2 years ago
parent
commit
cb75442845
  1. 2
      package.json
  2. 19
      src/core/platform/web/dom.js

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "fineui", "name": "fineui",
"version": "2.0.20221214115751", "version": "2.0.20221215171537",
"description": "fineui", "description": "fineui",
"main": "dist/fineui_without_conflict.min.js", "main": "dist/fineui_without_conflict.min.js",
"types": "dist/lib/index.d.ts", "types": "dist/lib/index.d.ts",

19
src/core/platform/web/dom.js

@ -250,12 +250,12 @@
_getLeftAlignPosition: function (combo, popup, extraWidth, container) { _getLeftAlignPosition: function (combo, popup, extraWidth, container) {
var comboRect = combo.element[0].getBoundingClientRect(), var comboRect = combo.element[0].getBoundingClientRect(),
popupRect = popup.element.bounds(), popupRect = popup.element[0].getBoundingClientRect(),
viewportRect = document.documentElement.getBoundingClientRect(), viewportRect = document.documentElement.getBoundingClientRect(),
containerRect = container ? container.getBoundingClientRect() : { left: 0 }; containerRect = container ? container.getBoundingClientRect() : { left: 0 };
var left = comboRect.left - containerRect.left + extraWidth; var left = comboRect.left - containerRect.left + extraWidth;
if (left + popupRect.width - containerRect.left > viewportRect.width) { if (comboRect.left + popupRect.width > viewportRect.width) {
left = viewportRect.width - popupRect.width - containerRect.left; left = viewportRect.width - popupRect.width - containerRect.left;
} }
return left; return left;
@ -265,12 +265,13 @@
var left = this._getLeftAlignPosition(combo, popup, extraWidth, container); var left = this._getLeftAlignPosition(combo, popup, extraWidth, container);
var dir = ""; var dir = "";
// 如果放不下,优先使用RightAlign, 如果RightAlign也放不下, 再使用left=0 // 如果放不下,优先使用RightAlign, 如果RightAlign也放不下, 再使用left=0
if (left < 0) { var containerRect = container ? container.getBoundingClientRect() : { left: 0 };
if (left + containerRect.left < 0) {
left = this._getRightAlignPosition(combo, popup, extraWidth); left = this._getRightAlignPosition(combo, popup, extraWidth);
dir = "left"; dir = "left";
} }
if (left < 0) { if (left + containerRect.left < 0) {
left = 0; left = 0 - containerRect.left;
} }
return { return {
left: left, left: left,
@ -412,7 +413,7 @@
}, },
getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) { getBottomAdaptPosition: function (combo, popup, extraHeight, needAdaptHeight) {
var comboBounds = combo.element.bounds(), popupBounds = popup.element.bounds(), var comboBounds = combo.element[0].getBoundingClientRect(), popupBounds = popup.element[0].getBoundingClientRect(),
windowBounds = BI.Widget._renderEngine.createElement("body").bounds(); windowBounds = BI.Widget._renderEngine.createElement("body").bounds();
if (BI.DOM.isBottomSpaceEnough(combo, popup, extraHeight)) { if (BI.DOM.isBottomSpaceEnough(combo, popup, extraHeight)) {
return BI.DOM.getBottomPosition(combo, popup, extraHeight); return BI.DOM.getBottomPosition(combo, popup, extraHeight);
@ -678,8 +679,8 @@
getComboPosition: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions, offsetStyle, positionRelativeElement) { getComboPosition: function (combo, popup, extraWidth, extraHeight, needAdaptHeight, directions, offsetStyle, positionRelativeElement) {
extraWidth || (extraWidth = 0); extraWidth || (extraWidth = 0);
extraHeight || (extraHeight = 0); extraHeight || (extraHeight = 0);
var bodyHeight = BI.Widget._renderEngine.createElement("body").bounds().height - extraHeight; var viewportBounds = document.documentElement.getBoundingClientRect();
var maxHeight = Math.min(popup.attr("maxHeight") || bodyHeight, bodyHeight); var maxHeight = Math.min(popup.attr("maxHeight") || viewportBounds.height, viewportBounds.height);
popup.resetHeight && popup.resetHeight(maxHeight); popup.resetHeight && popup.resetHeight(maxHeight);
var position = BI.DOM.getComboPositionByDirections(combo, popup, extraWidth, extraHeight, needAdaptHeight, directions || ["bottom", "top", "right", "left"], positionRelativeElement); var position = BI.DOM.getComboPositionByDirections(combo, popup, extraWidth, extraHeight, needAdaptHeight, directions || ["bottom", "top", "right", "left"], positionRelativeElement);
switch (offsetStyle) { switch (offsetStyle) {
@ -703,7 +704,7 @@
break; break;
} }
if (needAdaptHeight === true) { if (needAdaptHeight === true) {
popup.resetHeight && popup.resetHeight(Math.min(bodyHeight - position.top + (positionRelativeElement ? positionRelativeElement.getBoundingClientRect().top : 0), maxHeight)); popup.resetHeight && popup.resetHeight(Math.min(viewportBounds.height - position.top + (positionRelativeElement ? positionRelativeElement.getBoundingClientRect().top : 0), maxHeight));
} }
return position; return position;
}, },

Loading…
Cancel
Save