返回 slidev
code-magic-move.md
根目录 / skills / slidev / references / code-magic-move.md
1 ---
2 name: magic-move
3 description: Animate code changes with smooth transitions between code blocks
4 ---
5
6 # Shiki Magic Move
7
8 Animate code changes with smooth transitions (like Keynote's Magic Move).
9
10 ## Basic Usage
11
12 `````md
13 ````md magic-move
14 ```js
15 console.log(`Step ${1}`)
16 ```
17 ```js
18 console.log(`Step ${1 + 1}`)
19 ```
20 ```ts
21 console.log(`Step ${3}` as string)
22 ```
23 ````
24 `````
25
26 Note: Use 4 backticks for the wrapper.
27
28 ## With Line Highlighting
29
30 `````md
31 ````md magic-move {at:4, lines: true}
32 ```js {*|1|2-5}
33 let count = 1
34 function add() {
35 count++
36 }
37 ```
38
39 Non-code blocks in between are ignored.
40
41 ```js {*}{lines: false}
42 let count = 1
43 const add = () => count += 1
44 ```
45 ````
46 `````
47
48 ## How It Works
49
50 - Wraps multiple code blocks as one
51 - Each block is a "step"
52 - Morphs between steps on click
53 - Syntax highlighting preserved during animation
54
55 ## Resources
56
57 - Playground: https://shiki-magic-move.netlify.app/
58
58 lines MARKDOWN