Skip to content

Commit 009162f

Browse files
committed
feat: add useAnimationControls documentation for animation control methods
1 parent e51189d commit 009162f

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: useAnimationControls
3+
description:
4+
navigation.icon: 'lucide:play'
5+
---
6+
7+
`useAnimationControls` provides an imperative way to control animations, allowing you to precisely control when animations start, stop and reset through code.
8+
9+
`useAnimationControls` returns an animation controller with `start`, `stop`, `set` methods.
10+
11+
```vue
12+
<script setup lang="ts">
13+
import { useAnimationControls } from 'motion-v'
14+
15+
const controls = useAnimationControls()
16+
</script>
17+
```
18+
19+
The returned animation controller can be passed to a motion component's `animate` prop to control its animations:
20+
21+
```vue
22+
<Motion :animate="controls" />
23+
```
24+
25+
## Basic Usage
26+
27+
<ComponentPreview name="pan" />
28+
29+
## Methods
30+
31+
### start
32+
33+
Starts an animation with a transition effect. Takes a target state and optional transition config:
34+
35+
```ts
36+
controls.start({ x: 100 })
37+
```
38+
39+
### stop
40+
41+
Stops an animation.
42+
43+
```ts
44+
controls.stop()
45+
```
46+
47+
### set
48+
49+
Sets the animation to a target state without a transition effect.
50+
51+
```ts
52+
controls.set({ x: 100 })
53+
```

0 commit comments

Comments
 (0)