Reveal marked-up text word by word as scroll progress advances, while preserving semantic inline links, emphasis, responsive line wrapping, and reduced-motion r
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-scroll-scrubbed-word-reveal-1c1fabf349df ,按照其中的说明把「scroll-scrubbed-word-reveal」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Make reading progress visible without replacing real text, breaking inline markup, or depending on a fixed line count.
TreeWalker; do not flatten the container with textContent or innerHTML.script, style, form controls, and elements marked with [data-no-split].aria-hidden="true" only when an equivalent unsplit accessible copy remains available.Preferred structure:
<p class="reveal" data-reveal>
Motion should <em>explain</em> the next state, not decorate it.
</p>
Avoid line-based splitting. Browser line wraps must remain free to change with container width, language, zoom, and font loading.
Use section progress as the single source of truth:
const reveal = Math.min(1, Math.max(0, progress));
const local = Math.min(1, Math.max(0, reveal * wordCount - index));
word.style.setProperty("--word-progress", local);
Interpolate hidden opacity, blur, and vertical offset from --word-progress. Keep the visible state identical to normal typography.
Use GSAP ScrollTrigger with scrub when precise starts, ends, refresh, or a shared timeline is needed. Use a dependency-free scroll measurement plus requestAnimationFrame for a standalone section.
0.12–0.34–10px0.08–0.22em120–220% of the viewport for a paragraph10–30%Expose the values as CSS custom properties. Scale the scroll span from text length rather than assuming one duration fits every passage.
strong, em, marks, and accent spans keep their semantics and styling.prefers-reduced-motion: reduce, show every word immediately, remove blur and transforms, and remove any pinning.Kill ScrollTriggers, remove scroll and resize listeners, cancel animation frames, and restore the original marked-up subtree on route change or component unmount. Refresh measurements after fonts load if start or end positions depend on text geometry.
Test inline links and emphasis, punctuation, repeated spaces, long words, 200% zoom, 390/768/1440 widths, content changes, forward and reverse scrolling, reduced motion, keyboard focus, screen-reader reading order, and teardown. The final DOM must still communicate the complete sentence with JavaScript disabled.
Use demo/index.html as the working reference and demo/PROMPT.md to recreate or remix it. Keep REFERENCES.md as the links-only implementation source list.