MCPcopy Create free account
hub / github.com/Qinbf/groundmap / tick

Function tick

web/components/ScrollMemory.tsx:63–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

61 let stable = 0;
62 let frames = 0;
63 const tick = () => {
64 if (done) return;
65 frames += 1;
66 if (frames > MAX_FRAMES) {
67 el.scrollTop = top; // 布局迟迟不稳:精确还原一次后收手
68 settle();
69 return;
70 }
71 const h = el.scrollHeight;
72 if (h === last) {
73 stable += 1;
74 if (stable >= STABLE_FRAMES) {
75 el.scrollTop = top; // 布局稳定 → 精确还原
76 settle();
77 return;
78 }
79 } else {
80 last = h;
81 stable = 0;
82 el.scrollTop = top; // 仍在长高 → 每帧跟随目标,减少跳动
83 }
84 requestAnimationFrame(tick);
85 };
86 requestAnimationFrame(tick);
87
88 return settle;

Callers

nothing calls this directly

Calls 1

settleFunction · 0.85

Tested by

no test coverage detected