janpaepke / ScrollMagic

The javascript library for magical scroll interactions.
http://ScrollMagic.io
Other
14.88k stars 2.17k forks source link

Uncaught TypeError: Tween.getTweensOf is not a function #370

Open artemivanyk opened 9 years ago

artemivanyk commented 9 years ago

https://github.com/janpaepke/ScrollMagic/blob/master/dev/src/plugins/animation.gsap.js#L235

It has to do with the way gsap handles module definitions, which is, erhm... convoluted as already has been mentioned in an answer to https://github.com/janpaepke/ScrollMagic/issues/188#issuecomment-62907084

I guess a reliable way would be to just pick up TweenMax or TweenLite from the global gsap namespace.

janpaepke commented 9 years ago

Sorry, I don't quite understand what you're saying here :)

artemivanyk commented 9 years ago

After requiring the unminified version of animation.gsap plugin, I got an error in the browser. The name of this issue is the error I get. The first link is the line that throws it. It happened because whatever is returned from the gsap TweenMax module and assigned to Tween variable here is not TweenMax or TweenLite object. Therefore it doesn’t have getTweensOf method.

janpaepke commented 9 years ago

I understand, but what is it then? I mean it will need to be a TweenMax or TweenLite object for it to work...

artemivanyk commented 9 years ago

I understand, but what is it then?

I think @jackdoyle is in a better position to answer this one :-) Looks like in the case of TweenLite it is https://github.com/greensock/GreenSock-JS/blob/master/src/uncompressed/TweenLite.js#L1637 TweenPlugin object. In case of TweenMax it’s something else.

I mean it will need to be a TweenMax or TweenLite object for it to work...

In theory, yes. But in practice, I think, everyone just picks it from the global scope after requiring it. Like:

require('TweenMax');
// now TweenMax is available in global scope