Jump to content
Search Community

ScrollTrigger event onRefresh prevent play animation

_Greg _ test
Moderator Tag

Recommended Posts

Hi.

ScrollTrigger is great! 

I want to stop play again animation after i leave and back to browser tab.

As you can see on my example if you scroll down page to position when tl_inout played (green box will be on screen) and switch browser tab and then back (or just resize browser) - animation will start play from beginning.

 

I wan't that animation will be in same place (if before trigger it must be on progress(0), if after trigger - progress(1))

 

I think i do somthing wrong.

 

i try add this  but its not working:

onRefresh: ({progress, direction, isActive}) => {
  if(direction === 1){
    tl_inout.progress(1)
  }else if(direction === -1){
    tl_inout.progress(0)
  }
}

 

And sorry for my english

 

And sometimes you get result like on screen:

image.thumb.png.27a94e72f05924ea73e228b4a44dbbc9.png

See the Pen PoZoKEm?editors=0010 by -greg- (@-greg-) on CodePen

Link to comment
Share on other sites

12 minutes ago, Nekiy2 said:

Yes. Thank you! Everything works great! ❤️
GSAP is always on top

Can copy that version to my local project before release?

ScrollTriger with GSAP is the best!

Sure, be my guest. You can use that beta version if you'd like.

 

Happy scrolling!

Link to comment
Share on other sites

For others who read this...

 

The problem seems to be that the site was doing some loading or repositioning or resizing AFTER the initial load (which is when ScrollTrigger does a refresh()), thus the positioning was off. The solution was to simply call ScrollTrigger.refresh() when all of those tasks were done. 👍 From what I can tell, it wasn't a bug or problem with ScrollTrigger. 

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