Last active
November 4, 2023 21:30
-
-
Save rylanharper/56a3cb5b7c30a8f7b58e3f761ce11367 to your computer and use it in GitHub Desktop.
Nuxt3 GSAP NuxtPage Transition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <nuxt-page :transition="globalTransition" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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