greensock / GSAP

GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web
https://gsap.com
19.58k stars 1.72k forks source link

Why does this library expose tons of globals? #103

Closed chevcast closed 9 years ago

chevcast commented 9 years ago

Is there a version of GSAP that has everything contained within a namespace? My team won't let me use the library because they are apparently terrified of the handful of globals GSAP declares. Thanks!

jackdoyle commented 9 years ago

Ha. That's pretty funny (well, frustrating for you I'm sure). The short answer is "yes", you can simply define a GreenSockGlobals object before you load any GSAP files and it'll attach all the globals to that one object. For example:

<script>
var gs = window.GreenSockGlobals = {};
</script>
<script src='../src/TweenLite.min.js'></script>
<script>
gs.TweenLite.to(...);
</script>

There are specific reasons we expose a lot of globals, but I suspect that's not really what you care about at this point. Let me know if you want further explanation.

Does that help?