Directives
v-animate
Animates any element: in as it mounts, out as it leaves, to a new look when its values change, and to its new place when layout moves it. It plays on the same motion system as the components, so a ConfigProvider's spring, motion: false and reduced motion apply to it too. The Motion section covers it in depth, with examples for each case. It comes from vael-ui/motion; in a Vapor component, import vAnimateVapor from there instead (as vAnimate, or write v-animate-vapor).
Install
import { vAnimate } from 'vael-ui/motion'Examples
- Item 1
- Item 2
- Item 3
Names
The word after the colon, as in v-animate:rows, is a name. An element on its own doesn't need one. Name elements when they belong together: elements under one name that come in at the same time are one group, so stagger plays them one after another. Inside a vael-ui component, such as a Dialog, its motion.targets.rows sets how the elements named rows move, and they come and go with the component. after: 'rows' lets another element wait for them, and pages under one name can wait for each other with swap: 'wait'.
Name: elements with the same name are one group, so stagger plays them one after another and after: 'rows' lets another element wait for them.
Add a name only when something else has to point at the element: a stagger group, after, or a component's motion.targets. Otherwise leave it off.
<!-- On its own: no name. -->
<p v-animate.rise>Saved</p>
<!-- One group: they come in one after another. -->
<li
v-for="row in rows"
:key="row.id"
v-animate:rows.rise="{ stagger: true }"
>…</li>
<!-- In a component: they move with the dialog. -->
<Dialog :motion="{ targets: { rows: { initial: { y: 6 } } } }">
<li v-for="row in rows" :key="row.id" v-animate:rows>…</li>
</Dialog>