GreatHawkeye
Content Type
Profiles
Forums
Store
Blog
Product
Showcase
FAQ
Downloads
Posts posted by GreatHawkeye
-
-
@OSUblake, I was battling with my code for like 4 hours and you solved it in 10minutes, it works perfectly, thanks
- 3
-
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!
Get random numbers on each onComplete/onRepeat iteration
in GSAP
Posted
Hey guys,
sorry to bump up this thread again but I want to build my animations functions a little bit different now.
I've created a AnimationsManager.js where I put my eyesAnimations function :
And then use it in my main class :
Now the eyesAnimation will trigger only once and then lose the "target" parameter, it will console.log as undefined. How can I manage to use Tweens located in an utility file?
Thanks in advance !