Skip to content

Instantly share code, notes, and snippets.

@rylanharper
Last active November 4, 2023 21:30
Show Gist options
  • Select an option

  • Save rylanharper/56a3cb5b7c30a8f7b58e3f761ce11367 to your computer and use it in GitHub Desktop.

Select an option

Save rylanharper/56a3cb5b7c30a8f7b58e3f761ce11367 to your computer and use it in GitHub Desktop.
Nuxt3 GSAP NuxtPage Transition
<nuxt-page :transition="globalTransition" />
import { gsap, Expo, Power2 } from 'gsap'
export const globalTransition = {
name: 'global',
mode: 'out-in',
css: false,
onBeforeEnter(el) {
gsap.set(el, {
opacity: 0,
y: '12px'
})
},
onEnter(el, done) {
gsap.to(el, {
ease: Expo.out,
delay: 0.5,
opacity: 1,
y: 0,
onComplete: done
})
},
onLeave(el, done) {
gsap.to(el, {
ease: Power2.easeInOut,
duration: 0.3,
opacity: 0,
onComplete: done
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment