Green-Alpha Posted June 21, 2021 Share Posted June 21, 2021 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 More sharing options...
GreenSock Posted June 21, 2021 Share Posted June 21, 2021 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"}); 1 Link to comment Share on other sites More sharing options...
mikel Posted June 21, 2021 Share Posted June 21, 2021 Hey @Green-Alpha Does this case help? See the Pen jOBRXVK by mikeK (@mikeK) on CodePen Happy tweening ... Mikel 1 Link to comment Share on other sites More sharing options...
mikel Posted June 21, 2021 Share Posted June 21, 2021 ... or See the Pen mdWgaZp?editors=0110 by mikeK (@mikeK) on CodePen 1 Link to comment Share on other sites More sharing options...
Green-Alpha Posted July 8, 2021 Author Share Posted July 8, 2021 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 ! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now