Jump to content


Relative values referring variables

Recommended Posts

Let's say I have this animation:


tl.to('.video-react-video', {left: '-=325px', duration: 1, ease: "back.out(2.5)"}, 9);


How can I replace left: '-=325px' with left: '-=someVar'  


I tried creating a variable as 


const someVar = '325px'; and then use it as 

tl.to('.video-react-video', {left: '-=someVar', duration: 1, ease: "back.out(2.5)"}, 9); 


but it doesn't work. What would be the right syntax?

Link to comment
Share on other sites

Hi @Gilbert,


For a dynamic value you’ll want to do something like 



left: “-=“+someVar,


  • Like 3
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.