Jump to content
Search Community

gsap animations seems to end before it played to the end

iamruletik test
Moderator Tag

Go to solution Solved by Cassie,

Recommended Posts

Hello guys )
Trying to create animation in which whenever you hover over the specific text everything else but text dissapears and video became visible on the background. But I run into some problem. If I hover only on one text block and the leave it then it's working properly. But when I'm trying hover over few text blocks then sometimes some elements either became invisible or partly visible. Like animation starts and abruptly ends.

(Try to hover over "design and branding", "advertising", "web")

See the Pen MWzdZdW by iamruletik (@iamruletik) on CodePen

Link to comment
Share on other sites

Some of your elements are not in your minimal demo, so I had to remove them from the timeline. 

 

I think the only issue was that you were getting the hoverableLink's inside the loop. If you place the following outside the loop everything works as expected.

 

      let items = gsap.utils.toArray(hoverableLink);
 

Hope it helps and happy tweening! 

 

See the Pen PoxvLVW?editors=0011 by mvaneijgen (@mvaneijgen) on CodePen

Link to comment
Share on other sites

I believe the issue might be arising due to the presence of three separate animations that control the same elements. When I hover over one link, the entire text should become invisible. However, when I hover over the next link, the same text should also become invisible. In reality, it seems that the text begins to regain opacity from the mouseleave animation, and then another animation promptly starts, affecting the same text and causing it to become invisible. Unfortunately, the previous animation doesn't even get a chance to complete before this new animation takes over.

Link to comment
Share on other sites

  • Solution

Heya!

 

So the best approach here is likely just using tweens. Tweens are more dynamic and ideal for stuff like this. They'll take whatever the property value at that particular point in time is, no matter what it is, and tween to the property value you've specified.

See the Pen LYXoKGX?editors=0110 by GreenSock (@GreenSock) on CodePen



Timelines are great for control, but it can get fiddly if you're animating the same elements in multiple timelines. Sometimes using overwrite:auto and immediateRender:false can help get the behaviour you're after, there's also an invalidate() method that you can call on a timeline that flushes out stored starting values, that can also be helpful too.

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



But yeah, I'd likely go for tweens for anything more dynamic and event driven! 

Hope this helps ☺️

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