Jump to content
Search Community

Restart() not always working

GGiebler 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'm new to GSAP so I'm sure I'm doing something wrong.

 

I have the beginning of a game I'm working on:

 

www.giebler.com/IMS/iWin/Game/Game2.html

 

(My graphic designer hasn't animated the avatar yet).

 

While working on it, a tap or click of the mouse executes tl.restart() so I can repeat the animation.

 

However, after a few restarts, the avatar stops at the bridge for several of the timeline events, but eventually jumps to the end.

 

Can someone look at my source (above URL) and tell me what I'm doing wrong?

 

Thanks!

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

The only thing that jumped out in your code is that you are using a bad syntax for the position parameter.

 

relative string values should be "+=1.5" not "+1.5"

 

Not really sure that is related but its difficult for me to test, which is why we recommend that you provide a simplified CodePen demo:

 

http://greensock.com/forums/topic/9002-read-this-first-how-to-create-a-codepen-demo/

 

You should be able to paste your timeline code into a pen and just use simple, colored divs for map and avatar. The less code the better.

  • Like 3
Link to comment
Share on other sites

Hi Carl,

 

Thanks for the suggestion.  I modified all of my absolute times to relative times using the format you provided, but the animation still messes up when calling restart().

 

I decided to take a different approach, not using restart(), by creating a new instance each time I want to restart the animation.  

 

That is working perfectly, so I'll just avoid using restart() in my code.

 

Thanks,

 

Gary

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