Jump to content
GreenSock

bbnnt

Defining easing as a variable

Go to solution Solved by GreenSock,

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

I use different tween function at different points of a script; to clean code a bit, Id like to define things a bit more globally.

 

It might be an obvious question, but I could not find a clue about how to define the easing used in different tweenmax actions as a global variable.

 

Does it have to be accessed or defined specifically ?

Link to comment
Share on other sites

Hi bbnnt :)

 

try something like this :

 

var myEase = Back.easeIn;
var tl = new TimelineLite()

tl.to("#redBox", 1, {x:550,ease:myEase})
  .to("#blueBox", 1, {x:550,ease:myEase }, "-=0.5");
  • Like 2
Link to comment
Share on other sites

  • Solution

Yep, Diaco.AW is right. And also, you can define a different default ease like this:

TweenLite.defaultEase = Back.easeOut; //affects all subsequent tweens that are created and don't define an ease.
  • Like 1
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.
×