Hey guys,
First of all I'm using GSAP with React, it seems important to be told.
Here is the code :
eyesAnimation(target) {
//will give either 12 or -12
let rotation = Math.floor(Math.random()*2) == 1 ? 12 : -12
//will give random value from .5 to 2
let speed = Math.floor(Math.random() * 2 ) + .5
console.log(rotation)
TweenMax.to(target, speed, {
rotationZ: rotation,
delay: 3,
repeatDelay: 3,
yoyo: true,
repeat: -1,
onRepeat: this.eyesAnimation,
onRepeatParams:["{self}"]
})
}
this.eyesAnimation( this.eyes )
What I am trying to do is to get random values for my parameters (rotation, speed and later on delay etc...) on each onRepeat iteration.
The console.log will correctly display a random value in the console on each repeat but it wont apply it into the TweenMax, meaning the value that will be used on the next repeat will be the same as the previous one.
Can someone help?
Thanks!