Jump to content
Search Community

Playing and reversing animation on mouseenter

amit95 test
Moderator Tag

Go to solution Solved by Rodrigo,

Recommended Posts

I have an animation where on mouseenter, a logo animation plays. The way I'm trying to get this to work is:

 

  • primaryLogo is visible by default
  • Users mouse enters primaryLogo
  • primaryLogo fades out
  • secondaryLogo animates
  • Users mouse leaves secondaryLogo
  • secondaryLogo animates out (reverses)
  • primaryLogo fades back in

 

If a users mouse enters the default logo and then exits before the animation is finished, I still want the animation to play, reverse and go back to its initial state. Meaning once the animation plays, it needs to finish before restoring to original state.

 

To achieve this, I've tried:

 

tl.reversed() ? tl.play(0) : tl.reverse();

 

However, the animation then doesn't trigger.

 

A visual of the animation can be seen on mouseenter on the demo.

 

See the Pen yLjvEvx by amit_rai95 (@amit_rai95) on CodePen

Link to comment
Share on other sites

  • Solution

Hi,

 

I did some consulting in this exact same scenario a few years ago, only not with a logo but a SVG cards hover animations. The concept was the same, wait for the entire animation to play and then reverse it based on a few conditions. So luckily that got stuck in my brain :D

 

Hopefully this is what you're trying to achieve:

See the Pen jOxegge by GreenSock (@GreenSock) on CodePen

 

Happy Tweening!

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