From b33ce9ee690b49a662f8c9b30c041611e7613336 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Tue, 23 Apr 2019 17:17:18 +0800 Subject: [PATCH] =?UTF-8?q?BI-44035=20fix:=20popup=E4=B8=AD=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E8=BE=B9=E6=A1=86=E4=B8=8D=E9=9C=80=E8=A6=81-2=20&&?= =?UTF-8?q?=20position=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/layer/layer.popup.js | 2 +- src/core/platform/web/dom.js | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/base/layer/layer.popup.js b/src/base/layer/layer.popup.js index e1eb26f06b..ad9175c15a 100644 --- a/src/base/layer/layer.popup.js +++ b/src/base/layer/layer.popup.js @@ -156,7 +156,7 @@ BI.PopupView = BI.inherit(BI.Widget, { var tbHeight = this.toolbar ? (this.toolbar.attr("height") || 24) : 0, tabHeight = this.tab ? (this.tab.attr("height") || 24) : 0, toolHeight = ((this.tool && this.tool.attr("height")) || 24) * ((this.tool && this.tool.isVisible()) ? 1 : 0); - var resetHeight = h - tbHeight - tabHeight - toolHeight - 2 * this.options.innerVGap - 2; + var resetHeight = h - tbHeight - tabHeight - toolHeight - 2 * this.options.innerVGap; this.view.resetHeight ? this.view.resetHeight(resetHeight) : this.view.element.css({"max-height": resetHeight + "px"}); }, diff --git a/src/core/platform/web/dom.js b/src/core/platform/web/dom.js index 3d38627470..c2f37842e4 100644 --- a/src/core/platform/web/dom.js +++ b/src/core/platform/web/dom.js @@ -539,7 +539,7 @@ var i, direct; var leftRight = [], topBottom = []; var isNeedAdaptHeight = false, tbFirst = false, lrFirst = false; - var left, top, pos; + var left, top, pos, firstDir = directions[0]; for (i = 0; i < directions.length; i++) { direct = directions[i]; switch (direct) { @@ -649,39 +649,45 @@ } } + // 此处为四个方向放不下时挑空间最大的方向去放置, 也就是说我设置了弹出方向为"bottom,left", + // 最后发现实际弹出方向可能是"top,left",那么此时外界获取popup的方向应该是"top,left" switch (directions[0]) { case "left": case "right": if (BI.DOM.isRightSpaceLarger(combo)) { left = BI.DOM.getRightAdaptPosition(combo, popup, extraWidth).left; + firstDir = "right"; } else { left = BI.DOM.getLeftAdaptPosition(combo, popup, extraWidth).left; + firstDir = "left"; } if (topBottom[0] === "bottom") { pos = BI.DOM.getTopAlignPosition(combo, popup, extraHeight, needAdaptHeight); pos.left = left; - pos.dir = directions[0] + ",bottom"; + pos.dir = firstDir + ",bottom"; return pos; } pos = BI.DOM.getBottomAlignPosition(combo, popup, extraHeight, needAdaptHeight); pos.left = left; - pos.dir = directions[0] + ",top"; + pos.dir = firstDir + ",top"; return pos; default : if (BI.DOM.isBottomSpaceLarger(combo)) { pos = BI.DOM.getBottomAdaptPosition(combo, popup, extraHeight, needAdaptHeight); + firstDir = "bottom"; } else { pos = BI.DOM.getTopAdaptPosition(combo, popup, extraHeight, needAdaptHeight); + firstDir = "top"; } if (leftRight[0] === "right") { left = BI.DOM.getLeftAlignPosition(combo, popup, extraWidth, needAdaptHeight).left; pos.left = left; - pos.dir = directions[0] + ",right"; + pos.dir = firstDir + ",right"; return pos; } left = BI.DOM.getRightAlignPosition(combo, popup, extraWidth).left; pos.left = left; - pos.dir = directions[0] + ",left"; + pos.dir = firstDir + ",left"; return pos; } },