Jump to content
Search Community

Multiple TweenMax

TommyD test
Moderator Tag

Go to solution Solved by OSUblake,

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'm developing a Wordpress plugin which make use of your great library. As you can imagine other developers do the same and this could generate conflicts using multiple installations of TweenMax. I've followed what you suggested here: http://greensock.com/forums/topic/9881-avoid-multiple-loaded-tweenmax-and-tweenlite/ 

But I keep having problems. There's another plugin which includes TweenMax in this way:

var oldgs = window.GreenSockGlobals;
var oldgs_queue = window._gsQueue;
var my_gs = window.GreenSockGlobals = {};

// your library here..

try{
    window.GreenSockGobals = null;
    window._gsQueue = null;
    delete(window.GreenSockGlobals);
    delete(window._gsQueue);
} catch(e) {}

try{
    window.GreenSockGlobals = oldgs;
    window._gsQueue = oldgs_queue;
} catch(e) {}

This code is executed before mine. I've tried to do the same without luck. Here is my code:

var another_gs = window.GreenSockGlobals = {};

// your library here

window.GreenSockGobals = window._gsQueue = null;

I get this error: Uncaught TypeError: Cannot read property 'greensock' of undefined

And when I try to use it in this way

another_gs.TweenMax.to(..

another_gs is undefined.

 

 

Could you please help me solving this issue?

Many Thanks

Thomas

 

 

 

 

Link to comment
Share on other sites

Hi and thank for your answer. Yes, I'm sorry, Globals was misspelled but it's not the cause of my issue. my_gs is used by the other developers. Their code, which is executed before mine, is the following:

var oldgs = window.GreenSockGlobals;
var oldgs_queue = window._gsQueue;
var my_gs = window.GreenSockGlobals = {};

// your library here..

try{
    // They misspelled Globals!!!!!!!!!!!!
    // But I don't think that this is the cause
    window.GreenSockGobals = null;
    window._gsQueue = null;
    delete(window.GreenSockGlobals);
    delete(window._gsQueue);
} catch(e) {}

try{
    window.GreenSockGlobals = oldgs;
    window._gsQueue = oldgs_queue;
} catch(e) {}

Then I tried to use your code. This is included after the above one. Here is my code

var oldgs = window.GreenSockGlobals;
var oldgs_queue = window._gsQueue;
var wpppgs = window.GreenSockGlobals = {};

// your library here..

try{
    window.GreenSockGlobals = null;
    window._gsQueue = null;
    delete(window.GreenSockGlobals);
    delete(window._gsQueue);
  } catch(e) {}

  try{
    window.GreenSockGlobals = oldgs;
    window._gsQueue = oldgs_queue;
  } catch(e) {}

What happens here is that when this code is executed I get the following error:

 

Uncaught TypeError: Cannot read property 'greensock' of undefined

 

and if I try to call TweenMax in this way

 

plugin.timeline = new wpppgs.TimelineMax(tlObj);

// or also plugin.timeline = new TimelineMax(tlObj);

 

it returns

 

Uncaught ReferenceError: TimelineMax is not defined

 

If I force the other plugin to be executed after mine, the two works correctly. But, of course, I can have control over it and there could be other plugins producing the same issue. So I would need to find a way that allow my plugin to work together with any other using TweenMax, whether it's fired before mine or not.

 

Thanks!

Thomas

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...