Jump to content
Search Community

gsap.to(...) .reverse();

hellenson
Moderator Tag

Go to solution Solved by mvaneijgen,

Recommended Posts

hellenson
Posted

Hello,

I've made this animation a long time ago, and please, ignore how it looks, and I have an animation similar to this on a website, but I can't figure out why is there the ".reverse()" after gsap.to. It work just as I want it to, but I need to know how to explain everything, but I just don't know. The only thing that comes to mind, is that it "prepares" the function to be reversed after mouseleave.

Thanks anyone in advance

See the Pen yyLOjGd by Helena-Pacltov- (@Helena-Pacltov-) on CodePen.

hellenson
Posted

Well I might have just came up with my own answer... Is it that it sets the animation in "reverse" or into the original state, so that it is played only after the mouseenter?

  • Solution
mvaneijgen
Posted

This is for your t.reversed(!t.reversed()); f.reversed(!f.reversed()) logic, you set the reversed state to true, so that is plays forward on mouse enter and in reverse on mouse leave.

 

I would do the same by setting the reversed property on the tween it self, makes it more readable in my opinion. 

 

Hope it helps and happy tweening! 

 

See the Pen GggNOZg?editors=0010 by mvaneijgen (@mvaneijgen) on CodePen.

  • Like 2
hellenson
Posted

@mvaneijgen Okay, that looks much better and makes more sense! Thank you very much :))

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