Skip to content

Commit

Permalink
style: 当为 auto 定位时如果兜底的定位方式都显示不全的话直接平移到可视区域 (baidu#9628)
Browse files Browse the repository at this point in the history
  • Loading branch information
2betop committed Feb 20, 2024
1 parent 87b4dc2 commit 997e1bb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/amis-core/src/utils/dom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export function calculatePosition(
: overlayHeight / 2;

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

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

0 comments on commit 997e1bb

Please sign in to comment.