返回 slidev
layout-draggable.md
根目录 / skills / slidev / references / layout-draggable.md
1 ---
2 name: draggable-elements
3 description: Move, resize, and rotate elements by dragging during presentation
4 ---
5
6 # Draggable Elements
7
8 Move, resize, and rotate elements by dragging during presentation.
9
10 ## Directive Usage
11
12 ### With Frontmatter Position
13
14 ```md
15 ---
16 dragPos:
17 square: Left,Top,Width,Height,Rotate
18 ---
19
20 <img v-drag="'square'" src="https://sli.dev/logo.png">
21 ```
22
23 ### Inline Position
24
25 ```md
26 <img v-drag="[Left,Top,Width,Height,Rotate]" src="https://sli.dev/logo.png">
27 ```
28
29 ## Component Usage
30
31 ```md
32 ---
33 dragPos:
34 foo: Left,Top,Width,Height,Rotate
35 ---
36
37 <v-drag pos="foo" text-3xl>
38 Draggable content
39 </v-drag>
40 ```
41
42 ## Draggable Arrow
43
44 ```md
45 <v-drag-arrow />
46 ```
47
48 ## Controls
49
50 - Double-click: Start dragging
51 - Arrow keys: Move element
52 - Shift + drag: Preserve aspect ratio
53 - Click outside: Stop dragging
54
55 ## Auto Height
56
57 Set Height to `NaN` or `_` for auto height based on content.
58
58 lines MARKDOWN