Jump to content
GreenSock

scavaliere

ScrollTo specific section on page load + bugs on Chrome and Android

Recommended Posts

Hello everyone and TIA for all your support! 
I am making a landing page with GSAP, ScrollTo and ScrollTrigger plugins. 
As you can see from the Codepen, there is a simple scrolling animation with a specific duration on page load. The animation brings the user smoothly from A section to C section. 
While on Safari and Firefox (Win and Mac), the animation starts smoothly and correctly, on Chrome and Android browsers (Mi Browser in my case) it stops and it doesnt' run but after some seconds. It seems that duration in this case is read by Chrome like a delay and not the duration of the entire animation. 
The pen on Chrome explain exactly the problem, while on Safari or Firefox is running good.  

Anyone has an idea how to fix this strange behavior ? 

Thank you!

See the Pen abLmeRx by scavaliere (@scavaliere) on CodePen

Link to comment
Share on other sites

Looks to me like it's caused by the fact that you're loading bootstrap which applies scroll-behavior: smooth which screws it all up because GSAP tries to apply the new scroll position but the browser is like "NOPE! I'm gonna apply that gradually..." and then 60 times per second GSAP keeps trying to do it but the browser interferes. So when GSAP finally stops attempting to control the position, the browser is like "phew! Okay, now I'll start transitioning to that new value that GSAP set..." 🙄

 

Moral of the story: never, never use scroll-behavior: smooth if you're also trying to do scroll-related things with JS :)

 

html, body {
  scroll-behavior: auto;
}

https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior

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