Jump to content
Search Community

Repeat calls to animation in a javascript function

SteveJC test
Moderator Tag

Go to solution Solved by Cassie,

Recommended Posts

Hi, I want to create an animation that is run when a button is pressed. In the codepen link I have an animation that works. An image of a boy is first moved and then rotated. The boy is rotated twice using repeat: 1 in the tween that does the rotation. The good thing about it is that the button that calls this function can be pressed again and again and the animation works just fine.

 

However, it I want to repeat the entire timeline, not just the rotation tween, so I changed the code to have the repeat: 1 in the constructor of the timeline. The first button press is fine: the entire animation runs with the 'move and the rotation' run and repeated once. But, when the button is pressed again nothing happens.

 

How I can repeat a timeline which is run by clicking on a button and have it work each time the button is pressed?

Can you explain what I am doing wrong please?

 

See the Pen vYrjNMM by SteveJohn (@SteveJohn) on CodePen

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...