WurstCase Posted November 3, 2020 Share Posted November 3, 2020 I'd like to move an object in steps like shown in the example. Is there a way to do the stepping in a loop instead of using a new to() for each step? See the Pen oNLyEBO by wrrstcase (@wrrstcase) on CodePen Link to comment Share on other sites More sharing options...
Solution PointC Posted November 3, 2020 Solution Share Posted November 3, 2020 Hi @WurstCase Welcome to the forum. You could do something like this: gsap.to("#box", { duration: 1, x: "+=100", repeat: 11, repeatRefresh: true }); Happy tweening. 3 Link to comment Share on other sites More sharing options...
ZachSaucier Posted November 3, 2020 Share Posted November 3, 2020 If you need more variance you can use the approach that Craig gave above but use a functional value for your property (or properties). Or you could use a loop like you mentioned. You might learn some techniques from my article about animating efficiently. 2 Link to comment Share on other sites More sharing options...
WurstCase Posted November 3, 2020 Author Share Posted November 3, 2020 Aaaaand now I'm feeling stoopid for not having found repeatRefresh myself... 🥴 Many thanks to both of you! 2 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