1实现原理 · 为什么它能做到
画线动画靠 dash 机制:把 stroke-dasharray 设为整条路径长度、dashoffset 也设为同值(不可见),再把 offset 动到 0 即逐段显现
Draw the dash array as long as the path, offset it fully (invisible), then animate the offset to 0.
形变的前提是两条 d 的命令数量与类型一致,否则需要 MorphSVG 或 Flubber 这类重采样库
Paths interpolate point-by-point, so a naive morph requires both `d` attributes to have the **same number and type of commands**.
沿路径运动有三条实现路径(GSAP MotionPath、SMIL animateMotion 加 mpath、CSS offset-path),按是否需要滚动同步与库依赖选型
motionPath: { path: "#track", align: "#track", autoRotate: true, alignOrigin: [0.5, 0.5] },
渐变与滤镜也能被驱动(动 gradientTransform 或 stop offset 做扫光,动 feDisplacementMap.scale 与 feGaussianBlur.stdDeviation 做形变与对焦),但滤镜是 paint 重负
Filters are paint-heavy — animate sparingly and prefer `transform`/`opacity` where possible.
交付前必须有 SVG 工程纪律:SVGO 不能删掉可动画依赖(cleanupIds、removeViewBox),且必须内联 SVG 才能被 CSS 与 JS 触及
keep `viewBox`, drop editor metadata, but disable `cleanupIds`/`removeViewBox` and any plugin that renames IDs you reference from CSS/JS/SMIL.
2核心能力
3外部依赖
| 类型 | 依赖 |
|---|---|
| package | gsap 加 MorphSVGPlugin / MotionPathPlugin(可选:形变与沿路径运动) |
| package | flubber(可选:无 GSAP 的路径插值器) |
| cli | SVGO(可选:SVG 清洗与压缩,需关掉会破坏动画的插件) |
| api | 浏览器原语:SVGGeometryElement.getTotalLength()、SMIL animateMotion 与 mpath、CSS offset-path 与 offset-distance |
| network | 交付页可从 CDN 取 GSAP(产物期引用,不判级;正文未点名具体域) |
| cli | npx / Playwright(宿主侧截图工具)与仓库根 scripts/ 助手(seek-shot.sh、contact-sheet.sh 依赖 ffmpeg) |
4风险提醒 风险提醒:绿色 · 放心使用
- 内联第三方 SVG 的脚本面未被提示 — 内联 SVG(本 skill 的强制手法)可携带 script 与 onload 等事件属性;若把来路不明的 SVG 直接内联进宿主页面,等于执行其内联脚本。文档只谈 SVGO 清洗与 ID 保留,未提示该风险。
- SMIL 路径的取证依赖 helper 之外的手段 — seek-shot.sh 只能传 URL 参数,冻结 SMIL 需页面内自行调用 pauseAnimations 与 setCurrentTime;文档给了代码但未把它绑定到统一验收流程,SMIL 路径的自动化截图需自行接线。
- 许可声明不可核(见 second_pass) — MorphSVG 免费声明对商用有影响,仓库内无依据文件。
- 形变方案对路径结构有隐性要求 — 手写同构路径需设计侧配合(命令数量与类型一致),MorphSVG 与 Flubber 也非万能(点数差异过大时观感会崩);文档给了决策表但无质量判据。
5第二遍独立确认
- [ok] SMIL 的支持与弃用表述是否自洽 — SKILL.md 选型表给出 SMIL 适用面(自包含、无 JS bundle),并在 caveat 段说明 not supported in IE/old Edge and historically deprecation-flagged,要求滚动同步或最大兼容时改用 CSS 或 JS;references 第 4 节以三轴对比表重申,未夸大(未宣称 SMIL 已被移除)。
- [unlocatable] MorphSVG 是否真的免费可用(与 gsap-web 的免费声明同源风险) — SKILL.md 两次称 MorphSVG 在 GSAP 3.12+ 免费(**GSAP MorphSVG** (free as of GSAP 3.12)),但仓库内无上游许可文件可核,属外部事实声明,按文档声明记录(同仓 gsap-web 有同一处声明)。
- [ok] dashoffset 的两条取长度路线是否与 references 一致 — SKILL.md 的 Getting the length 两条(getTotalLength 与 pathLength="1")在 references 的 getTotalLength gotchas 与 No-JS normalization with pathLength 两节展开,且都附代码,前后一致。
- [discrepancy] Packaged helper 的路径基准与适用性 — SKILL.md 写 scripts/seek-shot.sh anim.html 0 1.5 3,scripts/ 在仓库根而非本 skill 目录;且 SMIL 驱动的冻结走 svg.pauseAnimations() 与 setCurrentTime(),helper 只替换 URL 参数,无法冻结 SMIL 时钟——对 SMIL 路径该 helper 失效。
6结论
7a0047bb3c20631d…b6dba3eb75