关于 slidev-click-animations
slidev-click-animations 是为 Slidev 演示文稿添加点击触发内容显示和动画的技能,涵盖分步呈现、内容切换、隐藏及动作变体。
主要功能
- 01点击触发内容显示
- 02指定或相对点击顺序
- 03使用 v-clicks 动画呈现列表
- 04按点击隐藏或切换内容
- 05适用于幻灯片状态的动作变体
适用场景
- 01逐条展示演示要点
- 02分阶段构建图示
- 03随点击切换页面内容
- 04演讲时突出显示内容
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ yoanbernabeu/ slidev-skills --skill slidev-click-animations安装后在 Claude Code 中输入/slidev-click-animations确认已加载。
详细介绍
Slidev 中的点击动画
此技能涵盖 Slidev 中所有基于点击的动画,包括 v-click、v-after、v-clicks、v-switch 和用于创建动态、引人入胜的演示文稿的 motion 指令。
何时使用此技能
- 逐步展示内容
- 构建复杂图表
- 营造悬念或强调重点
- 引导观众注意力
- 打造交互式演示流程
v-click 基础
组件语法
<v-click>
This appears on the first click
</v-click>
指令语法
<div v-click>
This also appears on click
</div>
多个 v-click
<v-click>First</v-click>
<v-click>Second</v-click>
<v-click>Third</v-click>
每次点击依次显示一个。
点击位置
显式位置
<div v-click="1">Appears first</div>
<div v-click="3">Appears third</div>
<div v-click="2">Appears second</div>
相对位置
<div v-click>First (click 1)</div>
<div v-click="'+1'">Second (click 2)</div>
<div v-click="'+2'">Fourth (click 4)</div>
同次点击(v-after)
<v-click>Main content</v-click>
<v-after>Appears with main content</v-after>
也可以使用相对位置:
<v-click>Main content</v-click>
<v-click="'+0'">Also appears with main</v-click>
用于列表的 v-clicks
基础列表动画
<v-clicks>
- First item
- Second item
- Third item
</v-clicks>
嵌套列表
<v-clicks depth="2">
- Parent 1
- Child 1.1
- Child 1.2
- Parent 2
- Child 2.1
</v-clicks>
每 N 项
<v-clicks every="2">
- Items 1-2 together
- (same click)
- Items 3-4 together
- (same click)
</v-clicks>
点击时隐藏
v-click.hide
<div v-click.hide>This disappears on click</div>
带 hide 的 v-click
<v-click hide>
This content will be hidden after the click
</v-click>
基于范围的隐藏
<div v-click.hide="[2, 4]">
Visible until click 2, hidden on clicks 2-3, visible again at click 4
</div>
v-switch
根据点击切换不同内容:
<v-switch>
<template #1>Content at click 1</template>
<template #2>Content at click 2</template>
<template #3>Content at click 3</template>
<template #4-6>Content at clicks 4, 5, and 6</template>
<template #default>Default content (before click 1)</template>
</v-switch>
实用示例
<v-switch>
<template #0>
<h2>Step 1: Initialize</h2>
<p>Set up the project structure</p>
</template>
<template #1>
<h2>Step 2: Configure</h2>
<p>Add configuration files</p>
</template>
<template #2>
<h2>Step 3: Build</h2>
<p>Run the build command</p>
</template>
</v-switch>
Motion 动画
基础 Motion
<div
v-motion
:initial="{ opacity: 0, y: 100 }"
:enter="{ opacity: 1, y: 0 }"
>
Slides up and fades in
</div>
带点击的 Motion
<div
v-motion
:initial="{ x: -100, opacity: 0 }"
:enter="{ x: 0, opacity: 1 }"
:click-1="{ scale: 1.2 }"
:click-2="{ x: 100 }"
:leave="{ opacity: 0 }"
>
Complex motion sequence
</div>
Motion 变体
| 变体 | 应用时机 |
|---|---|
initial | 初始状态 |
enter | 进入幻灯片时 |
click-N | 点击 N 时 |
click-N-M | 点击 N 至 M 期间 |
leave | 离开幻灯片时 |
Motion 属性
<div
v-motion
:initial="{
opacity: 0,
scale: 0.5,
x: -200,
y: 100,
rotate: -45
}"
:enter="{
opacity: 1,
scale: 1,
x: 0,
y: 0,
rotate: 0,
transition: {
duration: 500,
ease: 'easeOut'
}
}"
>
Animated element
</div>
点击计数器配置
设置总点击次数
---
clicks: 5
---
强制幻灯片恰好有 5 次点击。
自动点击
---
clicks: auto
---
自动确定点击次数(默认)。
设置点击状态的样式
CSS 类
当元素具有 v-click 时:
.slidev-vclick-target- 始终应用.slidev-vclick-hidden- 隐藏时应用.slidev-vclick-current- 当前激活的点击.slidev-vclick-prior- 已显示
自定义过渡
/* styles/index.css */
.slidev-vclick-target {
transition: all 0.5s ease;
}
.slidev-vclick-hidden {
opacity: 0;
transform: translateY(20px);
}
缩放动画
.slidev-vclick-target {
transition: all 0.3s ease;
}
.slidev-vclick-hidden {
transform: scale(0);
opacity: 0;
}
模糊效果
.slidev-vclick-hidden {
filter: blur(10px);
opacity: 0;
}
实用模式
构建列表
# Key Points
<v-clicks>
1. **Performance** - Optimized for speed
2. **Security** - Built-in protection
3. **Scalability** - Handles growth
4. **Maintainability** - Clean architecture
</v-clicks>
渐进式图表
# Architecture
<div class="grid grid-cols-3 gap-4">
<div v-click="1" class="box">Frontend</div>
<div v-click="2" class="box">API</div>
<div v-click="3" class="box">Database</div>
</div>
<Arrow v-click="4" x1="100" y1="100" x2="200" y2="100" />
<Arrow v-click="5" x1="300" y1="100" x2="400" y2="100" />
前后对比展示
# The Solution
<div v-click.hide="2">
<h2>Before</h2>
<pre>Old code here</pre>
</div>
<div v-click="2">
<h2>After</h2>
<pre>New improved code</pre>
</div>
动画高亮
# Important Concept
<p v-click="1">
This is a paragraph with
<span
v-motion
:initial="{ background: 'transparent' }"
:click-2="{ background: '#fef08a' }"
class="px-1"
>
highlighted text
</span>
that appears.
</p>
逐步展示代码
```typescript {1|2|3|all}
const name = 'Slidev'
const version = '0.50'
console.log(`${name} v${version}`)
```
最佳实践
1. 不要过度使用
❌ 点击次数过多
<v-click>Word</v-click>
<v-click>by</v-click>
<v-click>word</v-click>
<v-click>is</v-click>
<v-click>annoying</v-click>
✓ 有意义的分组
<v-click>First complete thought</v-click>
<v-click>Second complete thought</v-click>
2. 将相关内容分组
<v-click>
<h3>Feature A</h3>
<p>Description of feature A</p>
</v-click>
<v-click>
<h3>Feature B</h3>
<p>Description of feature B</p>
</v-click>
3. 考虑时机
<div v-click>Quick reveal</div>
<div
v-motion
:initial="{ opacity: 0 }"
:enter="{ opacity: 1, transition: { duration: 800 } }"
>
Dramatic reveal
</div>
4. 用于导航提示
<v-click at="1">
👉 First, we'll look at setup
</v-click>
<v-click at="2">
👉 Then, we'll implement features
</v-click>
<v-click at="3">
👉 Finally, we'll deploy
</v-click>
调试提示
- 检查点击次数:查看演示者模式中的点击计数器
- 确认位置:顺序很重要时使用显式位置
- 测试所有点击:演示前逐一点击所有动画
- 检查 CSS 冲突:自定义样式可能会造成干扰
输出格式
创建点击动画时:
# [Slide Title]
[Static introductory content if any]
<v-clicks>
- [Point revealed at click 1]
- [Point revealed at click 2]
- [Point revealed at click 3]
</v-clicks>
<v-click at="4">
[Conclusion that appears last]
</v-click>
---
CLICK SEQUENCE:
1. [What appears/happens]
2. [What appears/happens]
3. [What appears/happens]
4. [What appears/happens]
TOTAL CLICKS: [N]
评论
支持 Markdown