Jump to content
Search Community

Gsap installation in nuxt3

Md Helal Uddin test
Moderator Tag

Recommended Posts

Hey there!

 

Maybe this forum thread will be of some use.
 


Alternatively, if Nuxt 3's setup differs in some way to Nuxt 2, it may be worth popping into the Nuxt discord and asking some experts there. GSAP's core files don't differ in any way from any other modules, so you would just install them however Nuxt recommends!

https://discord.gg/ANE2AvgK

 

 

Here's our install helper too.

https://greensock.com/docs/v3/Installation

 

Link to comment
Share on other sites

  • 7 months later...
  • 2 weeks later...

Hey everyone!

 

Exciting times are ahead with the official launch of the first stable version of Nuxt3 a couple of weeks ago.

 

Here in GSAP Towers we want to give all of our users the best possible support, that's why we have this brand new GSAP Starter Template for all of you so you can see a simple setup for using GSAP in your Nuxt apps and sites:

 

https://stackblitz.com/edit/nuxt-starter-khrgsj?file=app.vue

 

As you can see it uses GSAP Context for super easy scoping and cleanup in your different Nuxt pages and components. You can learn more about it here:

https://greensock.com/docs/v3/GSAP/gsap.context()

 

Let us know if you have any questions, comments or issues.

 

Happy Tweening!

  • Like 7
Link to comment
Share on other sites

  • 1 month later...

Hi @katerlouis,

 

4 hours ago, katerlouis said:

I noticed in the nuxt starter template that you made `ctx` a reactive property using `ref()` – Why are you making it reactive? 

No particular reason, just wanted something that is kept through re-renders and accessible in the entire code, just that. Since there are no associated effects to the GSAP Context instance, updating it's value property will not trigger anything.

 

Of course changing it to this will work in the same way:

let ctx;

const toggleTimeline = () => {
  tl.value.reversed(!tl.value.reversed());
};
onMounted(() => {
  ctx = gsap.context((self) => {
    // Add GSAP instances here
  }, main.value) // <- Scope!
});

onUnmounted(() => {
  ctx.revert(); // <- Easy Cleanup!
});

Of course, if anyone finds any issue or performance problem, please report so we can take a good look.

 

Happy Tweening!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...