Jump to content
Search Community

Overlapping Tweens and repeat problem

SteveSargent 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

Hello,

 

The first time the animation runs all is fine but all subsequent timeline repeats miss out the first tween in the timeline. I know it's caused by the fact that the second tween overlaps the first tween on the same object but wondered if I'm doing something wrong as I wouldn't imagine this should cause issues. The problem is found on all browsers and devices

 

Thanks!

 

 

See the Pen oNNzJvy by JustShowingOff (@JustShowingOff) on CodePen

Link to comment
Share on other sites

22 minutes ago, SteveSargent said:

I know it's caused by the fact that the second tween overlaps the first tween on the same object but wondered if I'm doing something wrong as I wouldn't imagine this should cause issues.

 

When it overlaps, it kills the first x animation. Setting overwrite to false will prevent that.

 

var tl = new TimelineMax({repeat:-1});

tl.addLabel("start");
tl.to("#cat",0.5,{x:"+=300",ease:Quad.easeOut },"start");
tl.to("#cat",3,{x:"+=470", ease:Linear.easeNone, overwrite: false},"start+=0.4");

 

These are probably the 3 most used overwrite settings. The default is auto. In the next version of GSAP, false will be the default.

  • "none" (0) (or false) - no overwriting will occur.
  • "all" (1) (or true) - immediately overwrites all existing tweens of the same target even if they haven't started yet or don't have conflicting properties.
  • "auto" (2) - when the tween renders for the first time, it will analyze tweens of the same target that are currently active/running and only overwrite individual tweening properties that overlap/conflict. Tweens that haven't begun yet are ignored. For example, if another active tween is found that is tweening 3 properties, only 1 of which it shares in common with the new tween, the other 2 properties will be left alone. Only the conflicting property gets overwritten/killed. This is the default mode and typically the most intuitive for developers.

 

You can also tell when something gets overwritten like this.

 

See the Pen 06dcaf7668cb3925c779a7c7e57cb5c3 by osublake (@osublake) on CodePen

 

 

https://greensock.com/docs/v2/TweenLite/static.onOverwrite

https://greensock.com/docs/v2/TweenLite/static.defaultOverwrite

 

 

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