fix(mobile): 普通Popup钳高到铺满可视屏时顶端切出屏外(负top未写回)

实测发现:普通 Popup 高度被 CSS max-height 钳到 ≈window.innerHeight 时,
positify_tl 居中标定的负 top(如 -116px)仍留在内联样式里,弹窗顶端被切
到屏外上方。旧 _mobile_clamp 的 `if(t<0) t=0` 只改局部变量没写回元素,
且 `t+h>vh` 判断用置0后的 t 漏掉负 top 场景。

修法:钳制时读内联 top 原值 raw_t——h>=vh 时强制 top=0;否则把 top 钳进
[0, vh-h] 区间;只有 t!=raw_t 才 setProperty important(避免多余写样式)。
This commit is contained in:
yumoqing 2026-09-09 10:47:25 +08:00
parent 479cc3ba05
commit 1989a0f04f

View File

@ -336,12 +336,20 @@ bricks.Popup = class extends bricks.VBox {
el.style.setProperty('max-width', vw + 'px', 'important');
}
if (!is_win){
// 普通 Popup 定位钳制:确保整个弹窗落在可视屏内。
// 高度被钳到≈铺满可视屏时,强制 top=0否则居中的负 top 会把
// 顶端切出屏外上方);否则把 top 钳进 [0, vh-h] 区间。
var h = el.offsetHeight;
var t = parseFloat(el.style.top);
if (isNaN(t)) t = 0;
if (t < 0) t = 0;
if (t + h > vh){
el.style.setProperty('top', Math.max(vh - h, 0) + 'px', 'important');
var raw_t = parseFloat(el.style.top);
if (isNaN(raw_t)) raw_t = 0;
var t;
if (h >= vh){
t = 0;
} else {
t = Math.min(Math.max(raw_t, 0), vh - h);
}
if (t !== raw_t){
el.style.setProperty('top', t + 'px', 'important');
}
}
}