Skip to content

Commit

Permalink
fix: custom directives in Nuxt (#131) (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjboy76 authored Jun 21, 2023
1 parent bb30944 commit bf1af3f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 deletions.
30 changes: 17 additions & 13 deletions docs/content/1.getting-started/2.nuxt.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,23 @@ Then, configure your animations 🤹:
```javascript
{
// nuxt.config.js
motion: {
directives: {
'pop-bottom': {
initial: {
scale: 0,
opacity: 0,
y: 100
},
visible: {
scale: 1,
opacity: 1,
y: 0
},
runtimeConfig: {
public: {
motion: {
directives: {
'pop-bottom': {
initial: {
scale: 0,
opacity: 0,
y: 100,
},
visible: {
scale: 1,
opacity: 1,
y: 0,
}
}
}
}
}
}
Expand Down
28 changes: 16 additions & 12 deletions playgrounds/nuxt/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@ export default defineNuxtConfig({
},
],
},
motion: {
directives: {
'slide-rotate-top': {
initial: {
y: -400,
opacity: 0,
rotate: 90,
},
enter: {
y: 0,
opacity: 1,
rotate: 0,
runtimeConfig: {
public: {
motion: {
directives: {
'pop-bottom': {
initial: {
scale: 0,
opacity: 0,
y: 100,
},
visible: {
scale: 1,
opacity: 1,
y: 0,
},
},
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions src/nuxt/runtime/templates/motion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { defineNuxtPlugin, useRuntimeConfig } from '#app'

export default defineNuxtPlugin(
(nuxtApp) => {
const { motion: options } = useRuntimeConfig()

nuxtApp.vueApp.use(MotionPlugin, options)
const config = useRuntimeConfig()
nuxtApp.vueApp.use(MotionPlugin, config.public.motion)
}
)

0 comments on commit bf1af3f

Please sign in to comment.