Skip to content

Commit 1a38e95

Browse files
committed
fix(cat): align model transition at edges
修复猫形态和人形态切换时靠近屏幕边界的过渡遮罩偏移。\n\n- 过渡遮罩按猫/模型中心直接定位,允许遮罩部分出屏\n- 保持猫/模型实体原有边界夹取不变\n- 补充静态契约测试,防止重新把遮罩夹回视口
1 parent da56d92 commit 1a38e95

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

static/app-ui.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,12 +1853,10 @@
18531853
NEKO_MODEL_CAT_TRANSITION_MIN_SIZE,
18541854
Math.min(NEKO_MODEL_CAT_TRANSITION_MAX_SIZE, Math.round(basis * NEKO_MODEL_CAT_TRANSITION_SIZE_FACTOR))
18551855
);
1856-
const maxLeft = Math.max(0, window.innerWidth - size);
1857-
const maxTop = Math.max(0, window.innerHeight - size);
18581856

18591857
return {
1860-
left: Math.max(0, Math.min(Math.round(centerX - size / 2), maxLeft)),
1861-
top: Math.max(0, Math.min(Math.round(centerY - size / 2), maxTop)),
1858+
left: Math.round(centerX - size / 2),
1859+
top: Math.round(centerY - size / 2),
18621860
width: size,
18631861
height: size,
18641862
};

tests/unit/test_avatar_return_button_idle_tiers_static.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ def test_model_cat_transition_contract_is_present():
155155
assert "NEKO_MODEL_CAT_TRANSITION_MAX_SIZE = 680" in source
156156
assert "NEKO_MODEL_CAT_TRANSITION_SIZE_FACTOR = 0.86" in source
157157
assert "Math.round(basis * NEKO_MODEL_CAT_TRANSITION_SIZE_FACTOR)" in source
158+
transition_rect_block = source[
159+
source.index("function normalizeNekoTransitionRect(anchorRect, container, coverRect)"):
160+
source.index("function clearNekoModelCatTransitionOverlay()")
161+
]
162+
assert "left: Math.round(centerX - size / 2)" in transition_rect_block
163+
assert "top: Math.round(centerY - size / 2)" in transition_rect_block
164+
assert "maxLeft" not in transition_rect_block
165+
assert "maxTop" not in transition_rect_block
158166
assert "const transitionAnchorRect = savedGoodbyeRect || activeReturnButtonContainer.getBoundingClientRect()" in source
159167
assert "function mergeNekoTransitionAnchorRect(anchorRect, coverRect)" in source
160168
assert "const coverRect = options.coverRect || null" in source

0 commit comments

Comments
 (0)