iter(g106): 滚动监听改为卸载自清理

This commit is contained in:
HIsheR
2026-10-26 13:58:22 +08:00
parent 7d57f261df
commit c66bcf35da
6 changed files with 31 additions and 11 deletions
+2 -2
View File
@@ -3,6 +3,7 @@ import type { Signal } from '@ui-arch/frame';
import { pushOverlay } from './overlay.js';
import { button } from './button.js';
import type { TourHandle, TourProps } from './types.js';
import { watchViewport } from './watch.js';
/*** 引导漫游:聚光框 + 说明卡逐步指引,聚光用超大 box-shadow 挖洞省掉遮罩层,Esc / 跳过可退出 ***/
export function tour(props: TourProps): TourHandle {
@@ -84,8 +85,7 @@ export function tour(props: TourProps): TourHandle {
};
const onViewport = (): void => { if (idx() >= 0) place(); }; // 滚动/缩放后重算位置
window.addEventListener('resize', onViewport);
window.addEventListener('scroll', onViewport, { passive: true });
watchViewport(root, window, onViewport); // 节点脱离文档即自摘监听:引导层反复挂载也不累积
return {
el: root,