Jump to content
Search Community

Issue with simple animation on mouseenter and mouseleave

AsKadir test
Moderator Tag

Go to solution Solved by ZachSaucier,

Recommended Posts

Hey!
I have something like a button,

on mouseenter event timeline starts play,

then on mouseleave I want circle to dissapear and appear on starting point.

 

For the first time it works, but then on second mouseenter timeline not working.

 

What am I doing wrong? Can you help me, please?

See the Pen wvWxOmp by ChicagoJostik (@ChicagoJostik) on CodePen

Link to comment
Share on other sites

  • Solution

Hey Aslan. Some notes:

  • You should avoid animating width, left, and right properties. Instead try to stick to scale and x. 
  • You're calling .play() on a timeline that is already completed. This is the core of your issue. If you want it to restart, use .restart() instead.
  • It might be better to use a single timeline with an optional pause instead of a timeline and some tweens. That way you don't have a jump of state if someone hovers then unhovers before the hover animation completes. But it depends on what exactly you're hoping to create.
  • Like 1
Link to comment
Share on other sites

10 hours ago, ZachSaucier said:

You should avoid animating width, left, and right properties. Instead try to stick to scale and x. 

I understand this, but sometimes it can't be done without these properties.

Thanks a lot, Zach! Now everything is working!

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