Skip to content

Commit 29cefc2

Browse files
committed
style: 当为 auto 定位时如果兜底的定位方式都显示不全的话直接平移到可视区域
1 parent 87b4dc2 commit 29cefc2

File tree

1 file changed

+5
-1
lines changed
  • packages/amis-core/src/utils

1 file changed

+5
-1
lines changed

packages/amis-core/src/utils/dom.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export function calculatePosition(
169169
: overlayHeight / 2;
170170

171171
// 如果还有其他可选项,则做位置判断,是否在可视区域,不完全在则继续看其他定位情况。
172-
if (tests.length) {
172+
if (tests.length || isAuto) {
173173
const transformed = {
174174
x: clip.x + positionLeft / scaleX,
175175
y: clip.y + positionTop / scaleY,
@@ -200,6 +200,10 @@ export function calculatePosition(
200200

201201
if (visibleX && visibleY) {
202202
break;
203+
} else if (isAuto && tests.length === 0) {
204+
// 如果是 auto 模式,且最后一个方向都不可见,则直接平移到可见区域
205+
visibleY || (positionTop = window.innerHeight - transformed.height);
206+
visibleX || (positionLeft = window.innerWidth - transformed.width);
203207
}
204208
}
205209
}

0 commit comments

Comments
 (0)