Jump to content
Search Community

Animation ignores .addPause on repeat

doggard
Moderator Tag

Go to solution Solved by PointC,

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

Posted

Good afternoon,

I've been working on this animation to show a number rolling into view, as you might see on a digital altimeter.

My solution was to add pauses in the timeline so that the rolling number would pause for a moment when changing over.

 

The animation works as I would like it to at first, but when the animation begins to repeat, it appears to ignore the .addPause's that I have added.

 

I'm hoping that there may be a more elegant solution to my desired animation, or that someone may be able to help me understand why the pauses disappear when the timeline repeats.

 

Thanks!

See the Pen BjgMZj by doggard (@doggard) on CodePen.

  • Solution
Posted

Hi doggard  :)

 

Welcome to the forums.

 

Thank you very much for providing the CodePen. I think we can make your code quite a bit shorter using a loop. Then you wouldn't need to use the timeScale() and delayedCalls to get your pauses between numbers.

 

Here's what I used:

var ones = $('#ones'),
    tens = $('#tens'),
    childTl = new TimelineMax({repeat:-1});

TweenMax.set(ones, {yPercent:-90})
TweenMax.set(tens, {yPercent:-90})

for (i=0; i<10; i++) {
childTl.to(tens, .20, {yPercent:"+=9", ease:Linear.easeNone},"+=1") // the "+=1" is the pause - adjust to your liking
}

Here's a fork of your pen with that solution:

See the Pen BjXYdN by PointC (@PointC) on CodePen.

 

Hopefully that helps a little bit.

 

Happy tweening and welcome aboard.

:)

 

  • Like 3
Posted

This is exactly what I was looking for! Thanks so much for your quick response!

  • Like 2
Posted

You're welcome. I'm happy to help. 

 

Happy tweening. :)

  • Like 1
Posted

Welcome to the forums.

 

PointC's solution is definitely the way to go with this.

 

I just want to point out that the main reason the addPause() was not working on repeat was because you set the tween to repeat and not the timeline.

 

 

childTl.to(tens, 10, {yPercent:0, ease:Linear.easeNone, repeat:-1}) // not good
        .addPause(0, myFunction)
        .addPause(1, myFunction)
        .addPause(2, myFunction)
you would have needed to do

var childTl = new TimelineMax({repeat:-1}); // better

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