Jump to content
Search Community

TweenMax restart issues

Matt Severin test
Moderator Tag

Go to solution Solved by Carl,

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

  • Solution

Hi Matthew.

 

Hope things are well with you.

 

hmm, I'm not exactly sure what the desired result is supposed to look like but I noticed 2 things.

 

1: the timeline's that you were trying to restart had no duration.

 

fireTimeline.add(slingFire);
fireTimeline.pause();
resetTimeline.add(slingPull);
resetTimeline.pause();
 console.log("on app start fireTimeline duration = ", fireTimeline.duration())
 console.log("on app start resetTimeline duration = ", resetTimeline.duration())

both of those logs gave me 0.

 

The reason for this is that you were adding functions to your timelines NOT the timelines that those functions created.

 

These 2 lines were to blame

fireTimeline.add(slingFire);

resetTimeline.add(slingPull);

in order to call the slingFire function and get its returned timeline you need to invoke it with () like:

fireTimeline.add(slingFire());

same for

resetTimeline.add(slingPull());
I also noticed that some overwriting was occurring. This means that 2 animations were running at the same time fighting to control the same properties of the same target at the same time. When this happens the first tween gets overwritten (killed) which can cause problems if you try to play that animation again.
 
I put in some logs to help you find the troublesome animations
 
TweenLite.onOverwrite = function(overwriting, overwritten, target) {
  console.log("overwriting tween", overwriting)
  console.log("overwritten tween", overwritten)
  console.log("overwritten target", target)
}

You can read more about onOverwrite here: http://greensock.com/docs/#/HTML5/GSAP/TweenLite/onOverwrite/

 

Here is a fork of my demo with some updates

http://codepen.io/GreenSock/pen/VmKKRq?editors=0010

 

better?

 

 

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