Search code examples
javascriptcssiosscrolloverscroll

Snap back the page to inner scroll when user overscroll on IOS


I'm trying to build Tesla-clone app. I found the problem during the mobile usage of the app. On Tesla website when user try to overscroll, the page automatically snaps back. On the website is implemented inner scrolling with a snapping between sections, so when you overscroll, you're stucked and you can toggle the page back and force, but inner scrolling is not working, you have to wait till the page will snap back from overscrolled position. I hope i explained it so you can understand what i mean.

for reference: tesla.com

my website: https://axis-9f3a8.firebaseapp.com/

git of the page: https://github.com/FlipTaras/tesla-clone


Solution

  • window.addEventListener("touchmove", () => {
      window.scrollTo(0, 0);
    });
    

    Fixed the problem. Spend 6 hours of my life to figure it out.