Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Zlerp

Animation only starts on second hover.

Recommended Posts

I am using TweenLite to complete some SVG animations, but for some reason every time i reload the page, the first time I hover the element with the animation, the durration of the animation is instant. Then after the first time the hover effect is added instantly, the animation works properly.


 


Just rerun the code, hover the object and you will see the error I am receiving.


 


Any suggestions on why this is happening or a fix for it?


 


Thanks


See the Pen adEZzE by Zlerp (@Zlerp) on CodePen

Link to comment
Share on other sites

Hi Zlerp  :),

 

Welcome to the forums. 

 

If you change your CSS from this:

  .social-path, .social-circle {
    fill: none;
    stroke-width: 10;
  }

to this:

  .social-path, .social-circle {
    fill: transparent;
    stroke-width: 10;
  }

it will correct your problem. If you like, you can also shorten up your code quite a bit by using a Timeline and play()/reverse() on hover.

 

See the Pen adEZgX by PointC (@PointC) on CodePen

 

Hopefully this helps a bit. :)

 

  • Like 8
Link to comment
Share on other sites

Hi Zlerp.

Most of the times hover does not work as we want it to.

But you can use this code if you want.

 

$("nav").hover(function() {
/* Mouse enter */
var nav = $(this).removeClass("out");
setTimeout(function() {
nav.addClass("immediate");
}, 1000);

Link to comment
Share on other sites

Hello Zlerp,

 

I noticed that you are using jQuery animate() to set stroke-dashoffset and also using TweenLite to set your fill. If I were you I would use either jQuery animate() or TweenLite. the reason being is that they will both be competing to apply CSS properties on your element.

 

If i were you, I would opt for just TweenLite/Max GSAP, which will give you better performance and greater control. Using both will cause unforeseen issues cross browser. GSAP under the hood uses requestAnimationFrame() (RAF) which is better for smooth animation, whereas jQuery animate uses setInterval() for its timing.

 

Just trying to save you from headaches if you choose to use both jQuery animate() and GSAP on the same element. Since you don't want to make changes to elements outside of GSAP, so GSAP can keep track of what properties and values your changing outside of it.

 

:)

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