Communitygithub.com

David-Li0406/meta-skill-evloving

CSS 动画、过渡和滚动驱动效果,并注重无障碍性(尊重 prefers-reduced-motion)。在添加动效、悬停效果、加载状态或基于滚动的动画时使用。

meta-skill-evloving 是什么?

该技能专注于在 Web 开发中创建高性能且尊重用户偏好的 CSS 动画与过渡。它强调“减少动效优先”的理念,默认禁用动画,仅当用户未在系统设置中请求减少动效时才启用动画,从而避免用户在页面加载时看到不期望的闪烁。技能提供了详细的模式,通过 `prefers-reduced-motion` 媒体查询实现减动画替方案,例如将复杂的平移动画替换为更微妙的阴影过渡。它列举了性能安全的 CSS 属性(如 `transform` 和 `opacity`),这些属性由合成器直接处理,不会触发布局重排,并警告避免动画化 `width` 或 `top` 等昂贵属性。此外,技能涵盖了过渡模式(包括设计令牌集成)、关键帧动画(如脉冲、加载旋转器和骨架屏)、入场动画(淡入滑入、缩放)以及更高级的功能,如 View Transitions API 和滚动驱动动画。它还特别关注微交互(如按钮按压、开关切换和勾选动画),并提供了详细的测试指南,涵盖浏览器 DevTools 和操作系统设置。该技能支持所有现代浏览器,并与 `css-author`、`progressive-enhancement`、`performance` 和 `accessibility-checker` 等技能协同工作。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/David-Li0406/meta-skill-evloving/tree/HEAD/skill-flow/data/skills-refined-36k/skillsmp/animation-motion

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

动画与动效技能

本技能涵盖 CSS 动画和过渡,侧重于无障碍性(尊重用户动效偏好)和性能(避免卡顿和布局抖动)。

相关: 对于纯 CSS 交互模式(标签页、手风琴、切换开关,无需 JavaScript),请参阅 progressive-enhancement 技能。

理念

动效应遵循:

  1. 有目的性 - 引导注意力,展示关系,提供反馈
  2. 尊重性 - 尊重 prefers-reduced-motion 偏好
  3. 高性能 - 尽可能使用仅合成器属性
  4. 微妙性 - 增强体验,而非分散注意力或喧宾夺主

减少动效优先

始终以减少动效作为默认状态,然后仅为未选择退出的用户添加动效。

模式

/* 基础:无动效(减少动效的默认状态) */
.element {
  transition: none;
}

/* 仅在用户未请求减少动效时添加动效 */
@media (prefers-reduced-motion: no-preference) {
  .element {
    transition: transform 0.3s ease, opacity 0.3s ease;
  }
}

为什么减少动效优先?

方式问题
动效优先,再移除用户在媒体查询生效前看到动效闪烁
减少优先,再添加安全的默认状态,动效是渐进增强

尊重用户偏好

prefers-reduced-motion 媒体查询

/* 用户偏好减少动效 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

细粒度减少动效

与其移除所有动效,不如提供替代方案:

/* 为无偏好的用户提供完整动画 */
@media (prefers-reduced-motion: no-preference) {
  .card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }

  .card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
  }
}

/* 为减少动效的用户提供微妙的替代方案 */
@media (prefers-reduced-motion: reduce) {
  .card {
    transition: box-shadow 0.15s ease;
  }

  .card:hover {
    box-shadow: var(--shadow-md);
  }
}

JavaScript 检测

const prefersReducedMotion = window.matchMedia(
  '(prefers-reduced-motion: reduce)'
).matches;

if (prefersReducedMotion) {
  // 使用即时过渡或跳过动画
  element.style.transition = 'none';
} else {
  // 完整动画
  element.animate(keyframes, options);
}

性能安全属性

仅合成器属性(快速)

这些属性可以在不触发布局或绘制的情况下进行动画:

属性用途
transform移动、缩放、旋转
opacity淡入/淡出
filter模糊、亮度(GPU 加速)
/* 良好:仅合成器属性 */
.card:hover {
  transform: translateY(-4px) scale(1.02);
  opacity: 0.9;
}

应避免动画化的属性

这些属性会触发昂贵的布局重算:

属性问题
width, height布局重算
top, left, right, bottom布局重算
margin, padding布局重算
border-width布局重算
font-size布局 + 文本重排
/* 不良:触发布局 */
.card:hover {
  margin-top: -4px;  /* 布局抖动 */
  height: 110%;      /* 布局抖动 */
}

/* 良好:改用 transform */
.card:hover {
  transform: translateY(-4px) scaleY(1.1);
}

提升到合成器层

谨慎使用 will-change,仅用于已知动画:

/* 仅用于确定会动画的元素 */
.animated-element {
  will-change: transform, opacity;
}

/* 动画完成后移除 */
.animated-element.animation-done {
  will-change: auto;
}

警告: 不要对许多元素应用 will-change——这会消耗内存。


过渡模式

设计令牌集成

:root {
  /* 持续时间刻度 */
  --duration-instant: 0.1s;
  --duration-fast: 0.15s;
  --duration-normal: 0.3s;
  --duration-slow: 0.5s;

  /* 缓动函数 */
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

常见过渡

/* 悬停提升效果 */
@media (prefers-reduced-motion: no-preference) {
  .card {
    transition:
      transform var(--duration-fast) var(--ease-out),
      box-shadow var(--duration-fast) var(--ease-out);
  }

  .card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }
}

/* 焦点环 */
@media (prefers-reduced-motion: no-preference) {
  button {
    transition: outline-offset var(--duration-instant) var(--ease-out);
  }

  button:focus-visible {
    outline: 2px solid var(--focus-color);
    outline-offset: 2px;
  }
}

/* 淡入 */
@media (prefers-reduced-motion: no-preference) {
  .fade-in {
    animation: fadeIn var(--duration-normal) var(--ease-out);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

动画模式

关键帧动画

/* 用于吸引注意的微妙脉冲 */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@media (prefers-reduced-motion: no-preference) {
  .notification-badge {
    animation: pulse 2s var(--ease-in-out) infinite;
  }
}

/* 减少动效替代方案:无动画 */
@media (prefers-reduced-motion: reduce) {
  .notification-badge {
    animation: none;
  }
}

加载旋转器

/* 尊重减少动效的旋转器 */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
}

@media (prefers-reduced-motion: no-preference) {
  .spinner {
    animation: spin 1s linear infinite;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    /* 静态指示器或脉冲透明度 */
    animation: none;
    border-style: dotted;
  }
}

骨架屏加载

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-color) 25%,
    var(--background-alt) 50%,
    var(--surface-color) 75%
  );
  background-size: 200% 100%;
}

@media (prefers-reduced-motion: no-preference) {
  .skeleton {
    animation: shimmer 1.5s infinite;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
    background: var(--background-alt);
  }
}

入场动画

淡入和滑动

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .animate-in {
    animation: fadeSlideUp var(--duration-normal) var(--ease-out) both;
  }

  /* 交错子元素 */
  .animate-in > * {
    animation: fadeSlideUp var(--duration-normal) var(--ease-out) both;
  }

  .animate-in > *:nth-child(1) { animation-delay: 0ms; }
  .animate-in > *:nth-child(2) { animation-delay: 50ms; }
  .animate-in > *:nth-child(3) { animation-delay: 100ms; }
  .animate-in > *:nth-child(4) { animation-delay: 150ms; }
}

@media (prefers-reduced-motion: reduce) {
  .animate-in,
  .animate-in > * {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

缩放进入

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: no-preference) {
  dialog[open] {
    animation: scaleIn var(--duration-fast) var(--ease-out);
  }
}

View Transitions API

用于页面过渡(渐进增强):

/* 启用视图过渡 */
@view-transition {
  navigation: auto;
}

/* 默认交叉淡入 */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--duration-normal);
}

/* 尊重减少动效 */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.01ms;
  }
}

/* 特定元素的命名过渡 */
.hero-image {
  view-transition-name: hero;
}

::view-transition-old(hero),
::view-transition-new(hero) {
  animation-duration: var(--duration-slow);
}

滚动驱动动画

现代 CSS 滚动驱动动画(渐进增强):

/* 滚动时淡入 */
@keyframes fadeInOnScroll {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: no-preference) {
  .scroll-reveal {
    animation: fadeInOnScroll linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scroll-reveal {
    opacity: 1;
    transform: none;
  }
}

微交互

按钮按压

@media (prefers-reduced-motion: no-preference) {
  button {
    transition: transform var(--duration-instant) var(--ease-out);
  }

  button:active {
    transform: scale(0.98);
  }
}

切换开关

.toggle-track {
  width: 44px;
  height: 24px;
  background: var(--surface-color);
  border-radius: 12px;
}

.toggle-thumb {
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transform: translateX(2px);
}

@media (prefers-reduced-motion: no-preference) {
  .toggle-thumb {
    transition: transform var(--duration-fast) var(--ease-out);
  }
}

.toggle-input:checked + .toggle-track .toggle-thumb {
  transform: translateX(22px);
}

复选框勾选

.checkbox-icon {
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
}

@media (prefers-reduced-motion: no-preference) {
  .checkbox-icon {
    transition: stroke-dashoffset var(--duration-fast) var(--ease-out);
  }
}

.checkbox-input:checked + .checkbox-box .checkbox-icon {
  stroke-dashoffset: 0;
}

动画持续时间指南

动画类型持续时间原因
微交互100-150ms即时反馈
简单过渡150-300ms可察觉但快速
复杂动画300-500ms有足够时间跟随
页面过渡300-500ms上下文切换
加载指示器1000-2000ms可见一个周期

100ms 规则

如果响应时间低于 100ms,用户会感觉动作是即时的。将此用于:

  • 按钮激活状态
  • 焦点指示器
  • 切换开关

应避免的危险模式

前庭触发

这些可能导致晕动症或癫痫发作:

模式问题替代方案
视差滚动前庭问题静态或微妙的视差
自动播放视频意外动效通过交互触发播放
闪烁(>3Hz)癫痫风险不要闪烁
大幅缩放前庭问题淡入过渡
旋转/转动方向感迷失淡入或滑动
/* 不良:激进的视差 */
.parallax {
  transform: translateY(calc(var(--scroll) * 0.5));
}

/* 更好:微妙或在减少动效时禁用 */
@media (prefers-reduced-motion: reduce) {
  .parallax {
    transform: none;
  }
}

无限动画

/* 不良:持续动效 */
.attention-seeker {
  animation: bounce 1s infinite;
}

/* 更好:有限次数 */
.attention-seeker {
  animation: bounce 1s 3; /* 仅 3 次 */
}

/* 最佳:通过交互触发 */
.attention-seeker:hover {
  animation: bounce 0.5s;
}

测试清单

浏览器 DevTools

  1. Chrome: Rendering > Emulate CSS media feature > prefers-reduced-motion: reduce
  2. Firefox: about:config > ui.prefersReducedMotion (0=no-preference, 1=reduce)
  3. Safari: Develop > Experimental Features > Reduced Motion

系统设置

  • macOS: System Preferences > Accessibility > Display > Reduce motion
  • iOS: Settings > Accessibility > Motion > Reduce Motion
  • Windows: Settings > Ease of Access > Display > Show animations
  • Android: Settings > Accessibility > Remove animations

检查清单

添加动画或过渡时:

  • 尊重 prefers-reduced-motion
  • 减少动效有有意义的替代方案(不仅仅是禁用)
  • 仅动画化合成器属性(transform、opacity)
  • 谨慎使用 will-change,并在动画后移除
  • 一致性使用持续时间令牌
  • 没有闪烁内容(每秒超过 3 次闪烁)
  • 无限动画有其目的,并且可以停止
  • 视差和大幅动效是可选增强
  • 加载状态在没有动画的情况下也能工作
  • 动画增强体验而非分散注意力

相关技能

  • css-author - 使用原生 @import、@layer 层叠的现代 CSS 组织
  • progressive-enhancement - HTML 优先的开发,纯 CSS 交互模式
  • performance - 编写性能友好的 HTML 页面
  • accessibility-checker - 确保 WCAG2AA 无障碍合规

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

David-Li0406/meta-skill-evloving

Browser automation with persistent page state. Use when users ask to navigate websites, fill forms, take screenshots, extract web data, test web apps, or automate browser workflows. Trigger phrases include "go to [url]", "click on", "fill out the form", "take a screenshot", "scrape", "automate", "test the website", "log into", or any browser interaction request.

David-Li0406/meta-skill-evloving

Create technical diagrams using Mermaid syntax for architecture, sequences, ERDs, flowcharts, and state machines. Use for visualizing system design, data flows, and processes. Triggers: diagram, mermaid, architecture diagram, sequence diagram, flowchart, ERD, entity relationship, state diagram, C4 model, component diagram, visualize, draw.

David-Li0406/meta-skill-evloving

Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. When Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks

David-Li0406/meta-skill-evloving

Complete color manipulation and green screen effects system. PROACTIVELY activate for: (1) Green screen/chromakey removal, (2) Color grading with LUTs, (3) Color correction (levels, curves, white balance), (4) Colorkey/color removal effects, (5) Hue/saturation manipulation, (6) Color space conversions (BT.709, BT.2020, HDR), (7) Color isolation effects, (8) Teal and orange look, (9) Vintage/film looks, (10) Color keying for transparency. Provides: chromakey and colorkey filters, LUT application (lut3d), curves and levels adjustment, color balance, selective color manipulation, color space handling, HDR tone mapping, professional color grading chains.

David-Li0406/meta-skill-evloving

Convert files and office documents to Markdown. Supports PDF, DOCX, PPTX, XLSX, images (with OCR), audio (with transcription), HTML, CSV, JSON, XML, ZIP, YouTube URLs, EPubs and more.

David-Li0406/meta-skill-evloving

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

David-Li0406/meta-skill-evloving

Build with OpenAI's stateless APIs - Chat Completions (GPT-5, GPT-4o), Embeddings, Images (DALL-E 3), Audio (Whisper + TTS), and Moderation. Includes Node.js SDK and fetch-based approaches for Cloudflare Workers. Use when: implementing chat completions with GPT-5/GPT-4o, streaming responses with SSE, using function calling/tools, creating structured outputs with JSON schemas, generating embeddings for RAG (text-embedding-3-small/large), generating images with DALL-E 3, editing images with GPT-Image-1, transcribing audio with Whisper, synthesizing speech with TTS (11 voices), moderating content (11 safety categories), or troubleshooting rate limits (429), invalid API keys (401), function calling failures, streaming parse errors, embeddings dimension mismatches, or token limit exceeded.

David-Li0406/meta-skill-evloving

Comprehensive PDF manipulation toolkit for extracting text and tables, creating new PDFs, merging/splitting documents, and handling forms. When Claude needs to fill in a PDF form or programmatically process, generate, or analyze PDF documents at scale.

David-Li0406/meta-skill-evloving

Presentation creation, editing, and analysis. When Claude needs to work with presentations (.pptx files) for: (1) Creating new presentations, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes, or any other presentation tasks

David-Li0406/meta-skill-evloving

Comprehensive spreadsheet creation, editing, and analysis with support for formulas, formatting, data analysis, and visualization. When Claude needs to work with spreadsheets (.xlsx, .xlsm, .csv, .tsv, etc) for: (1) Creating new spreadsheets with formulas and formatting, (2) Reading or analyzing data, (3) Modify existing spreadsheets while preserving formulas, (4) Data analysis and visualization in spreadsheets, or (5) Recalculating formulas

David-Li0406/meta-skill-evloving

Download YouTube videos with customizable quality and format options. Use this skill when the user asks to download, save, or grab YouTube videos. Supports various quality settings (best, 1080p, 720p, 480p, 360p), multiple formats (mp4, webm, mkv), and audio-only downloads as MP3.

David-Li0406/meta-skill-evloving

Best practices for Remotion - Video creation in React

David-Li0406/meta-skill-evloving

Provides bidirectional translation (Chinese/English), grammar checking, and sentence polishing. Supports specific tense constraints, context-aware tone adjustment, and natural expression optimization. Outputs direct text without formatting.

David-Li0406/meta-skill-evloving

指导如何通过自定义注解(如@Unicom)标识Dubbo接口,利用BeanDefinitionRegistryPostProcessor在启动时扫描并动态注册ReferenceBean,实现RPC调用的封装。

David-Li0406/meta-skill-evloving

生成Python脚本,利用FFmpeg将图片序列按3x3布局合并,或将合并图拆分。要求使用subprocess模块执行命令,并支持用户交互式输入路径。

David-Li0406/meta-skill-evloving

SOP for extracting and analyzing promotional activity details, handling time formatting, location mapping, payment logic, and step-by-step process validation.

David-Li0406/meta-skill-evloving

Specializes in creating TikTok short video scripts using an anthropomorphic 'Chef' perspective to explain wildlife food chains and survival environments, utilizing real field footage.

David-Li0406/meta-skill-evloving

针对TikTok平台,以拟人化视角(如动物作为厨师)创作系列短视频脚本。重点介绍野生动物、食物链及生态环境,要求使用野外实拍素材,风格幽默且具有教育意义。

David-Li0406/meta-skill-evloving

Generates KWL (Know, Want to know, Learned) charts for educational videos, specifically BrainPOP, using simple 7th-grade language and short, concise bullet points.

David-Li0406/meta-skill-evloving

Tracks complex, multi-session work using the Beads issue tracker and dependency graphs, and provides persistent memory that survives conversation compaction. Use when work spans multiple sessions, has complex dependencies, or needs persistent context across compaction cycles. Trigger with phrases like "create task for", "what's ready to work on", "show task", "track this work", "what's blocking", or "update status".

相关技能