跳到正文
Skillpedia
网站与界面(前端)75k · #3077

view-transitions

它能做什么

这个技能使用浏览器的 View Transitions API,在页面状态和屏幕之间添加流畅的动画。它面向构建单页或多页网站的开发者。

适用场景

  • ✓页面切换显得突兀,用户失去方向感的时候。
  • ✓一张图片应平滑地展开为详情视图的时候。
  • ✓检查网站是否使用了浏览器现在可以原生处理的动画库的时候。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/view-transitions/SKILL.md

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

使用方法

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

可直接粘贴的消息

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

可以这样问 AI

“我的应用切换页面时感觉很突兀。请帮我添加流畅的切换效果,但不引入大型动画库吗?”

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

工作原理

智能体会用浏览器的过渡调用包裹页面切换,并为需要单独动画的元素命名。浏览器会在切换前后拍摄快照,然后在两者之间做动画。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Use the View Transitions API for smooth page and component transitions

Jarring instant page changes are one of the most noticeable perceived- performance problems in web applications. Smooth transitions help users maintain context during navigation — they understand where they came from and where they are going. Previously, achieving this required complex JavaScript animation libraries; the View Transitions API delivers it natively at a fraction of the code cost.

Quick Reference

  • Wrap DOM mutations in document.startViewTransition() for same-page transitions
  • Add view-transition-name to elements that should animate individually (not the whole page)
  • Use @starting-style and ::view-transition-* pseudo-elements to customise animations
  • Enable cross-document transitions in CSS with @view-transition { navigation: auto }

Check

Check whether the site uses the View Transitions API or a JavaScript animation library for page and component transitions.

Fix

Implement view transitions using document.startViewTransition() for SPA route changes or @view-transition for MPA cross-document navigation.

Explain

Explain how the View Transitions API captures before/after snapshots and animates between them, and how view-transition-name enables shared-element transitions.

Code Review

Review transition implementation for missing prefers-reduced-motion guards, duplicate view-transition-name values (must be unique per snapshot), and transitions that may cause layout thrash in the old/new state.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/css/view-transitions

常见问题

这需要 JavaScript 库吗?

这个技能说,View Transitions API 内置于浏览器,因此省去了动画库所需的大部分代码。

过渡效果应该尊重减少动效设置吗?

应该。这个技能把缺少 prefers-reduced-motion 保护列为需要修复的问题。

view-transition-name 有什么用?

它让某个元素可以单独做动画,例如在两个页面之间共享的图片。

详情

作者的原始描述

Use when adding page transition animations, image expand/contract effects, shared-element transitions, or improving navigation UX in a single-page or multi-page application.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#3077
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能