Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Rob

onRepeat does not fire for each repetition that occurs when tab is inactive.

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

Hey guys,

Found some behaviour that's causing me issues.

I have an animation of a vehicle, that's yoyo-ing from left to right infinitely. In the onRepeat callback i'm flipping scaleX between 1 & -1 to flip the graphic.

 

The problem happens when the browser tab is not active.

The timeline may have repeated multiple times, however the onRepeat callback is only fired once when focus is returned to the tab.

 

Therefore the orientation of the graphic can become out of sync with the actual direction.

 

I realise that RAF halts all callbacks when the tab is inactive so, but I would have expected the onRepeat callback to be fired retroactively for the number of times the animation has technically repeated.

 

Is the behaviour intended or a GSAP bug?

 

For the moment I have changed my code to manually change direction based on the x vector in the onUpdate callback.

 

Hope I've not rambled too much :)

Look forward to your reply.

 

Rob

 

Link to comment
Share on other sites

Hey Rodrigo

Many thanks for the message, that looks like exactly what I need!

Sorry for the duplication.

 

Rob

Link to comment
Share on other sites

Don't worry, glad it helped.

 

Cheers

Rodrigo

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.

×