Loading...
Loading...
Build animations in a Nuxt app with nanime, the Nuxt module wrapping Anime.js v4. Use when animating elements, text, SVG or scroll in Nuxt: useAnimate, useWaapiAnimate, useAnimatable, useAnimeTimeline, useDraggable, useSplitText, useScrambleText, useAnimeScroll, useAnimeLayout, <AnimeTransition>, <AnimeTransitionGroup>, <AnimeLayoutGroup>, transition styles, component defaults, provideAnimeDefaults and the #nanime/* aliases. Also use when an effect seems to need raw animejs, GSAP or CSS transition classes. Most mistakes here do not throw; they animate the wrong thing.
npx skill4agent add onmax/nuxt-skills nanimeonMountedanimejs| Building | Use | Details |
|---|---|---|
| Animating elements, refs, arrays, plain objects | | |
| Values set imperatively at speed (cursor follow, live counter) | | |
| Sequencing | | timelines.md |
| Scroll-driven animation | | timelines.md |
| Text split into lines, words, chars | | timelines.md |
| Scrambling or revealing text | | |
| SVG draw, morph, motion path | | timelines.md |
| Dragging with snap, bounds, axis locks | | lists.md for draggable list items |
| | transitions.md |
| | transitions.md, lists.md |
| Mounted elements changing position or size (FLIP) | | layout.md |
| Testing an animation without a browser | verifying.md |
animejs| Alias | Holds |
|---|---|
| Anime.js types ( |
| Anime.js utils ( |
| |
| |
| |
| Both of the above |
useAnimeScroll(() => ({ target: section.value ?? undefined })) // correct
useAnimeScroll({ target: section.value }) // silently wrongnulldocument.body.valueT | nullT | undefined?? undefinedsetupfunction onClick() {
useAnimate(box, { x: 100 }) // leaks: no effect scope, never reverted
}animate#nanime/utilsimport { animate } from '#nanime/utils'
import type { JSAnimation } from '#nanime/types'
const pulse = shallowRef<JSAnimation | null>(null)
onScopeDispose(() => pulse.value?.revert())
function highlight(el: HTMLElement) {
pulse.value?.revert()
pulse.value = animate(el, { scale: [1, 1.1, 1], duration: 400 })
}sync()const scroll = useAnimeScroll(() => ({ target: section.value ?? undefined, sync: true }))
useAnimate(box, { x: 400, autoplay: scroll })useAnimeScroll{{ animation.progress }}const progress = ref(0)
useAnimate(box, { x: 400, onUpdate: self => progress.value = self.progress })useScrambleTextuseSplitText<script setup lang="ts">
useScrambleText(title, {}, () => ({ text: track.value.title }))
</script>
<template>
<h2 ref="title" v-once>{{ track.title }}</h2>
</template>useSplitTextv-oncehtmlscrambleText()durationdelayeaseuseScrambleTextuseScrambleText(title, { onComplete: next }, () => ({ text: text.value, duration: 2000 }))depsdeps<AnimeTransitionGroup><AnimeLayoutGroup>deps<AnimeTransitionGroup :deps="[]"> <!-- moves on add, remove, reorder -->
<AnimeTransitionGroup :deps="[view]"> <!-- also when view resizes items -->
<AnimeLayoutGroup :deps="[expanded]"> <!-- only when expanded changes -->:deps="[]"<AnimeLayoutGroup><AnimeTransitionGroup>:move-animation="false"nanime.reducedMotionnuxt.config.ts'never''system'prefers-reduced-motion'always'useDraggableuseAnimeScrollupdateAppConfig({ nanime: { reducedMotion } })prefers-reduced-motion{ keepTime: true }useAnimateuseAnimeTimelineuseScrambleTextuseAnimatable