Jump to content
Search Community

Repeat Until

Green-Alpha test
Moderator Tag

Recommended Posts

Hello, is there a way to make a tween repeat for a duration ? I saw another topic but the goal was not exactly the same.

A simple example : I have a 1 minute animation, and while it's playing, an heart is beating every 750ms. To make the heart beat as long as the animation run, I have to specify the repeat by making some calculations.

Is there a way to avoid adjusting repeat every time I add tweens to the main animation ? Like a tricky way like a property {
repeatUntil : 'someLabel'
}

It's possible to set a repeat to -1 and then stop it using a callback, but maybe you have another way to achieve this ?

Thanks

Link to comment
Share on other sites

I'm not sure I totally follow what you're wanting to do, but you can just create an infinitely-repeating tween that's paused and then use ANOTHER tween to animate its totalTime to whatever you want. 

 

let tween = gsap.to(".heartbeat", {..., repeat: -1, paused: true});
gsap.to(tween, {totalTime: 1, duration: 1, ease: "none"});

 

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

Thanks for these answers :)

 

Interesting solution GreenSock, so in this case if I'm right, the heartbeat become a parallel animation, i'll give it a try !

For the second pen of Mikel, it's close to what I'm trying to do, but in your example the "time" animation is 5s, but the pulse overflow the "time". But I need to stop the pulse animation when the first timeline is complete.

 

Thank you for your time !

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