Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSAP and Lenis layout shift. #2

Open
thesoldiersway opened this issue Sep 28, 2024 · 1 comment
Open

GSAP and Lenis layout shift. #2

thesoldiersway opened this issue Sep 28, 2024 · 1 comment

Comments

@thesoldiersway
Copy link

thesoldiersway commented Sep 28, 2024

It's an old problem that there are articles about since more than ten years or longer. That mobile browser developers don't fix it is absurd because it limits the design of web pages. As I read, there are thousands of people who are disappointed. The problem is the layout shift on mobile when you scroll down and the address field disappears. The website makes an unpleasant jump then, which can also be noticed in this demo. Scroll down to the text and up and you will see it. It gets even worse if you have a 3d model, parallax or something else on the website. There are various solutions online but none of them really work. I don't mind the address field on the mobile. Some web designers like Anderson Mancini also have fixed address bar but he builds in app. Should I choose between a jumping, layout-shifting web page or a visible address field, I of course choose the address field. To bypass the layout shift, I found a code on GSAP that works. Also tested it on this demo and Lenis has become even smoother scrolling. I added the code on the bottom of the html code before the body tag. Try it,

<script> ScrollTrigger.config({ ignoreMobileResize: true}) ScrollTrigger.normalizeScroll(true); // enable </script>
@13papatya
Copy link

Can you add this code to the style.css and give a try?
html, body {scroll-behavior: auto;}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants