Jump to content
Search Community

Repeating animation with random value not working properly after 1st repeat

iggy test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

I am trying to create an animation of rotating wrench with varying rotation degree.

 

To create random rotation angle on each repeat, I followed the advice from this post.

 

I finally got it to work, however after 1st round of repeat, the wrench barely moved.

 

This is what I am trying to do:

1311726753_Screenshot2019-01-2719_12_18.png.bf53c7ee63e42ff384cb12e1fa54d0ac.png

 

The code that I have is not doing step#3, after it rotated at random angle, it did not return to original position. If what I am observing is correct, it goes to the next randomRotationValue. 

 

Hope I am clear what I am trying to do vs what I actually did - how can I achieve the desired effect?

See the Pen rPeoON by iggyDood (@iggyDood) on CodePen

Link to comment
Share on other sites

The main problem is that once you tweened to the destination value (between 20 and 30 in your case), you never tweened it back to 0, so after the first time, it was just going from whatever random value (between 20 and 30) to another random value in the same range. That'd make it look like it's not moving much. 

 

The transformOrigin looked a bit off to me too. Here's a reworked version of your codepen: 

 

See the Pen c921c5beb018a96da6a79c6474a29395 by GreenSock (@GreenSock) on CodePen

 

Does that help? 

 

Oh, and thanks so much for providing a reduced test case in codepen! That made troubleshooting much easier. 

 

Happy tweening!

 

  • Like 3
  • Haha 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...