Jump to content
GreenSock

Remco

GSAP.defaults different for FROM and TO

Recommended Posts

Hi all! 

 

I love to set some defaults at the start of my project, like the default duration and ease. 

Is it possible to set defaults specific for FROM or TO animations?

 

Something like this:

gsap.defaults({
                'from': {
                  ease:     'power3.in',
                  duration: 0.6
                },
                'to': {
                  ease:     'power1.out',
                  duration: 0.2
                }
              });

Any idea?

  • Like 1
Link to comment
Share on other sites

Not like that I'm afraid but you could do this...

 

It's a little more repetitive, but less so than writing out the properties every time
 

let fromdefaults = {
  some: stuff,
  some: morestuff,
}

tl.from('.elem', {
  yPercent: 200,
  ...fromDefaults
})

 

Link to comment
Share on other sites

Thanks Cassie, that's nice solution which im using too for now. 

 

Maybe in a future version of GSAP :)

  • Like 1
Link to comment
Share on other sites

You also might be interested in registerEffect()

 

Once you put a little time into making an effect, they require very little code to customize

 

See the Pen LYNBZww by snorkltv (@snorkltv) on CodePen

  • Like 3
Link to comment
Share on other sites

Never thought of that for my solution. Thanks Carl! 

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