Jump to content
Search Community

How to set ease outside tween call?

ombilic test
Moderator Tag

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

Lets say I have this setup:

 

startPos = [0, 0, 0]

endPos  = [1, 2, 3]

 

How can i specify an easing function for this tween?

 

TweenLite.to(startPos, 1, endPos)

 

Doing endPos.ease = someEase before the tween call results in someEase undefined as expected.

 

tl;dr: Where are the easing functions in this library, TweenLite.path.to.easings?

Link to comment
Share on other sites

As I am coming from other tweening libraries that have the easing functions as properties of  the tween object, the problem turned out to be the fact that i did not iclude the easings pack. Now all your examples work Diaco. Thanks!

 

One more question though. Isn't this solution against Javascript ethics. Having so many vars doesn't "pollute" the global namespace?

Why did you guys choose this way and not something like this:

endPos.ease = TweenLite.Easings.Bounce.easeIn;

Sorry if I am beeing too curios.

Link to comment
Share on other sites

Not at all - I love the curiosity. Totally valid question. There are several reasons we handled it this way:

  1. To minimize typing (clean code). It could really bloat the code you have to write if we packaged/nested things that way
  2. To match the way GSAP worked in Flash. One of the biggest draws for high-end animators coming from Flash was that the API was identical in JS. 

That being said, if you WANT to have GSAP dump all its stuff into a single root object that you name yourself, that's totally possible using the GreenSockGlobals variable. GSAP looks for that at the root and if it finds it, that's where it'll put everything. So the system was designed with a lot of flexibility. If that's how you prefer to operate, go for it. 

var gsap = window.GreenSockGlobals = {};
//then load the JS files, and then...
gsap.TweenLite.to(...);

Does that answer your question? 

  • 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.
×
×
  • Create New...