3

I'm trying to implement full-size browser viewport scrolling using a CSS scroll-snap. But there is a problem with Chrome on Android (tested in 91 version): when the address bar shifts (at first scroll or on scroll direction change) scroll element can shake or/and scroll just partially — not to the correct element point. Please see a code snippet.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div class="wrapper">
    <div class="wrapper__el" style="background: green">1</div>
    <div class="wrapper__el">2</div>
    <div class="wrapper__el" style="background: green">3</div>
    <div class="wrapper__el">4</div>
    <div class="wrapper__el" style="background: green">5</div>
    <div class="wrapper__el">6</div>
    <div class="wrapper__el" style="background: green">7</div>
    <div class="wrapper__el">8</div>
    <div class="wrapper__el" style="background: green">9</div>
  </div>
  
  <style>
    html, body {
      height: 100%;
      margin: 0;
    }
    .wrapper {
      position: fixed;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      scroll-snap-type: mandatory;
      scroll-snap-type: y mandatory;
      overflow: scroll;
    }
    .wrapper__el {
      scroll-snap-align: start;
      scroll-snap-stop: always;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
    }
  </style>
  
</body>
</html>

Perhaps there are some ways to make this work smoothly and accurately using the CSS scroll-snap? At the same time, I would like to left the address bar moving in/out on Chrome on Android, as it is intended in this browser.

Oleksandr
  • 31
  • 2
  • I have the same issue on chrome. When I swipe in one direction and swipe once again before the animation is completed, the slider freeze position and does not snap until I swipe again. I've seen some demo on chrome that did not suffer this but was unable to determine what fixed it. – Max Aug 18 '21 at 14:09

0 Answers0