Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Cyboide

Future Library Conflicts

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi,

 

I was just wondering, seeing the way other libraries are made and used, like jQuery, Modernizr, Raphael (I think), etc., if conflicts could not happen at some point ahead, between GSAP and other libraries.

 

For example, using Modernizr has to begin with their name. Modernizr.functionName. For jQuery, it is the usual $.doSomething. As to prevent conflicts.

 

For GSAP, it is sort of all global packages. And the way Javascript works...

Because it is not only TweenMax/Min and Timeline, but also all the plugins and utils. It’s starting to be a lot of globals with their own names.

 

Maybe (unless I see it the wrong way??) in some future release, could, or should, the GSAP be used something like GS.tweenMax.to(); GS.draggable... etc.

(Or maybe I don’t understand what you did to prevent conflicts)

Link to comment
Share on other sites

No need to worry - there is already a mechanism in place for this. You can set up a namespace if you want by setting the window.GreenSockGlobals property before you load GreenSock classes. For example, you could place this in the root:

var gs = window.GreenSockGlobals = {};
...then load GreenSock files..
gs.TweenLite.to(...);

When GSAP loads, it looks for the window.GreenSockGlobals object and if it finds one, it'll attach all of its stuff there. 

 

In reality, most people would rather not have to type an extra prefix like "gs." before anything GreenSock-related. And we wanted to maintain parity between the way developers referenced GSAP tools in Flash and JavaScript. So the default is to just use a global, but if you don't like that for whatever reason, you can certainly have GreenSock tuck all of its stuff into another object instead. 

 

Is that what you were looking for? 

  • Like 2
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.
×