Sowjanya Posted December 7, 2021 Share Posted December 7, 2021 I want a new random number every time the timeline restarts, here is the code: gsap.registerPlugin(CustomEase, CustomWiggle); let tl = gsap.timeline(); CustomBounce.create("bounce", { strength: 2, squash: .1, }); tl.to(".box", 3, { x: 'random(-200, 200)', y: 'random(-200, 195)', ease: "bounce", onComplete: tl.restart() }) See the Pen VwMeJZR by sowg (@sowg) on CodePen Link to comment Share on other sites More sharing options...
Solution akapowl Posted December 7, 2021 Solution Share Posted December 7, 2021 Hello @Sowjanya You could either invalidate() your tl before you play it again ... See the Pen NWaNGYg by akapowl (@akapowl) on CodePen ... or use repeats and set repeatRefresh: true. See the Pen zYEqvWM by akapowl (@akapowl) on CodePen If it always starting start from the center again is what you're going for, I guess you will have to use a fromTo tween then, though. Hope that helps 3 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