Jump to content
Search Community

TimelineMax call with repeat and delays appears to fire twice

Jimmi Heiserman 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've been staring at this for too long, some maybe I just need a second set of eyeballs on this.

I really thought this single line of code should fire once every 3 seconds (after the initial 6 second wait period).

But it appears to be firing twice at the same time after the first solo-fire. I must have some flawed understanding of how repeat + repeatDelay + delay works.

 

I was expecting:

nothing for first 6 seconds

call function and log some text with random number

wait 3 seconds

call function and log some text with random number

wait 3 seconds

call function and log some text with random number

wait 3 seconds

etc... 

new TimelineMax({repeat:-1, repeatDelay:3, delay:6}).call(func);

 

 

See the Pen mzWRXG?editors=1111 by jimmi_heiserman (@jimmi_heiserman) on CodePen

 

 

See the Pen mzWRXG?editors=1111 by jimmi_heiserman (@jimmi_heiserman) on CodePen

Link to comment
Share on other sites

Nah, you just created a really awkward scenario where you've got a zero-duration timeline and a callback at the VERY beginning. I'll spare you the lengthy explanation, but here's a much better setup: 

 

new TimelineMax({repeat:-1, delay:3}).add(func, 3);

 

Or:

new TimelineMax({repeat:-1, delay:3}).call(func, null, null, 3);

 

Or:

new TimelineMax({repeat:-1, onRepeat:func, delay:3}).to({}, 3, {});

 

Or:

new TimelineMax({repeat:-1, onRepeat:func, delay:3}).set({}, {}, 3);

 

(I could go on with more options, but you get the idea) :)

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