Jump to content
Search Community

GSAP installation requirement

Funhyun test
Moderator Tag

Recommended Posts

Hi GSAP experts!

 

I am new in developing GSAP. In general, do I need to add registeredPlugin codes after the first line of code in the JS file? Any advice is greatly appreciated. Thanks in advance! 😀

 

import gsap from 'gsap';

// Is this code below needed if I want to use ScrollTrigger and ScrollSmoother plugins?
gsap.registerPlugin(ScrollTrigger, ScrollSmoother);

 

Link to comment
Share on other sites

That's the idea.

You can also set gsap.defaults before gsap.registerPlugin too...

My first few lines on a typical GSAP project are:

'use strict';
gsap.defaults({overwrite: "auto"});
gsap.registerPlugin(CSSRulePlugin, ScrollToPlugin, ScrollTrigger, TextPlugin);
  • Like 2
Link to comment
Share on other sites

I cannot find where I did it, but im rather sure I used registerPlugin in conditional statements in various places without problems.

I usually do not use build tools though (for a lot of reasons) and as I make sure to load gasp and  the plugins in the correct order registerPlugin is redundant for me in most cases anyhow.

 

My understanding however is that usually  there should b no need to place registerPlugin always on top as long as you register the plugin before you use it - if it is necessary, but I giving my limited experience with build tools I might be wrong and would happily hear form those who are in the know - and also surely it is nothing wrong with registering at the start of a JS file as a convention. 

  • Like 1
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...