Sembiance Posted January 28, 2020 Share Posted January 28, 2020 Greetings In 2.x you could set window.GreenSockGlobals = {}; and GreenSock would put all it's variables into that object, avoiding the global window namespace. In 3.1.1 the same thing doesn't seem to have any effect, as all the variables are in the global namespace window.gsap, window.gsapVersions, etc. Any way to force 3.x to stick to just 1 global var? I like to keep the global namespace as unpolluted as possible. Thanks! Link to comment Share on other sites More sharing options...
OSUblake Posted January 28, 2020 Share Posted January 28, 2020 GreenSockGlobals is still there, but I think it will still install everything as a global. It's more for using different versions of gsap on the same site. To get rid of all the globals, you can use modules and everything will be scoped to the module. See the Pen fac322113bc12c54959ea2cda1287b0f by osublake (@osublake) on CodePen 2 Link to comment Share on other sites More sharing options...
Sembiance Posted January 28, 2020 Author Share Posted January 28, 2020 Thanks! Link to comment Share on other sites More sharing options...
GreenSock Posted January 29, 2020 Share Posted January 29, 2020 Yep, @OSUblake is correct. Just use the modules. For the record, @OSUblake, internally GSAP 3 does indeed honor the GreenSockGlobals object just like in v2.x but when Rollup creates the ES5 UMD files it assigns all the exports to the window! So it's the bundler doing that, not GSAP. I'm not sure there's a super clean solution for that, quite frankly. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now