浏览代码

fix: let the headline rest while the glass period is pulled away

The pull captures the pointer, so the headline's weight wave kept
getting moves after the lens left it and turned every letter thin until
release. Moves outside the headline now count as leaving it; pulling the
lens back across the letters still melts them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEPoSHwHCYMNpm2iKxY9hL
Claude 1 月之前
父节点
当前提交
87407ee6ce
共有 1 个文件被更改,包括 7 次插入 和 1 次删除
  1. 7 1
      components/cards/hero-title.tsx

+ 7 - 1
components/cards/hero-title.tsx

@@ -131,9 +131,15 @@ export function HeroTitle() {
     const onMove = (e: PointerEvent) => {
       if (e.pointerType === "touch") return;
       const { clientX: x, clientY: y } = e;
+      // Pulling the bead captures the pointer, so moves keep arriving once it
+      // has left the headline: out there the letters rest, as on leaving.
+      const r = wrap.getBoundingClientRect();
+      const inside = x >= r.left && x <= r.right && y >= r.top && y <= r.bottom;
 
       cancelAnimationFrame(frame);
-      frame = requestAnimationFrame(() => setWeights(near(x, y)));
+      frame = requestAnimationFrame(() =>
+        setWeights(inside ? near(x, y) : () => null),
+      );
     };
     const onLeave = () => {
       cancelAnimationFrame(frame);