跳到正文
Skillpedia
动效与动画7.2k · #13464

scroll-scrubbed-word-reveal

它能做什么

这个技能让滚动来控制标题、引语或声明的阅读节奏,每个词依次出现。适合希望文字以稳定节奏被阅读的编辑类和营销页面。

适用场景

  • ✓当引语或宣言需要在读者滚动时逐词出现时。
  • ✓当段落中的链接或强调在显现过程中仍需正常工作时。
  • ✓当你希望文字在任何屏幕宽度下和减少动效时都保持可读时。

技能链接

https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/scroll-scrubbed-word-reveal/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/scroll-scrubbed-word-reveal/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我希望宣言中的标题在人们滚动时逐词出现,同时保证链接仍然可以点击。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会保留页面中的原始文字,把单词包裹在 span 中,但不破坏行内链接或强调,并根据滚动位置为每个词设定进度值。经过每个词时,它会淡入并上升。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Scroll-Scrubbed Word Reveal

Make reading progress visible without replacing real text, breaking inline markup, or depending on a fixed line count.

Prepare the text

  1. Keep one untouched accessible text source in the DOM.
  2. Walk text nodes with TreeWalker; do not flatten the container with textContent or innerHTML.
  3. Skip script, style, form controls, and elements marked with [data-no-split].
  4. Replace only non-whitespace tokens with spans and preserve whitespace nodes exactly.
  5. Mark generated spans 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.

Map scroll to words

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.

Set useful defaults

  • Hidden opacity: 0.12–0.3
  • Blur: 4–10px
  • Vertical offset: 0.08–0.22em
  • Reveal span: 120–220% of the viewport for a paragraph
  • Direct word overlap: 10–30%
  • Easing: none for the scroll mapping; ease only the visual interpolation when needed

Expose the values as CSS custom properties. Scale the scroll span from text length rather than assuming one duration fits every passage.

Preserve emphasis

  • Let links, strong, em, marks, and accent spans keep their semantics and styling.
  • Use inherited color by default; style accents on the original element, not on token indexes.
  • Do not reveal essential links only on hover or after the reader has passed them.
  • Re-split only when the source text changes. Responsive wrapping does not require rebuilding tokens.
  • Store enough state to restore the original DOM during cleanup.

Keep it readable

  • Use real document flow; pin only when the copy and evidence justify a short deliberate reading beat.
  • Do not use a typewriter cursor, random delays, or autoplay unless explicitly requested.
  • Under prefers-reduced-motion: reduce, show every word immediately, remove blur and transforms, and remove any pinning.
  • Keep screen-reader output natural and avoid announcing each word.
  • Verify contrast in both the hidden and final states; hidden words may be quiet but the final text must meet the normal reading contract.

Clean up

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.

Verify

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.

常见问题

它会破坏文字中的链接吗?

不会。该技能说明只包裹单词本身,从而保留行内标记。

屏幕阅读器还能读取这些词吗?

能。该技能在拆分单词时保留一份可访问的完整文本副本。

它会按行拆分文字吗?

不会。它避免按行拆分,以便文字能自然换行。

详情

作者的原始描述

Reveal marked-up text word by word as scroll progress advances, while preserving semantic inline links, emphasis, responsive line wrapping, and reduced-motion readability. Use for headlines, quotes, manifestos, product statements, onboarding messages, or editorial passages where scrolling should pace comprehension rather than simulate typing.

repo: MengTo/Skills

热度

GitHub 星标
7.2k
排名
#13464
许可证
MIT
更新时间
2026/11/1

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能