Hi there,
I can't seem to get this working. I have a bunch of bubbles that I want to yoyo, and once that yoyo is complete I want it to go towards a new, random direction (both x and y). I want the initial x,y starting values to remain the same, but the bubbles to move towards a new directed for each timeline refresh.
Is this possible? Below is everything I have tried
PS I would submit a codepen, but the code is complicated since it deals with JSX. I can't seem to get it working on codepen
useLayoutEffect(() => {
bubArray.forEach(x => {
gsap.set((`.bubble-${x}`), {
position: 'absolute',
x: gsap.utils.random(0, 500),
y: gsap.utils.random(0, 500)
})
let btl = gsap.timeline()
btl.to(`.bubble-${x}`, {
y: gsap.utils.random(0, 500),
x: gsap.utils.random(0, 500),
duration: 3,
yoyo: true,
repeat: 1,
repeatRefresh: true,
onComplete: () => {btl.invalidate(); btl.restart(true)}
})
})