Search code examples
htmlcsswebkitscroll-snap-points

Single scroll-snap-point with bottom of viewport before the last section of the page


I have a question concerning snapping-points in CSS (resource, browser-support). I want to scroll completely normal throughout the body until a latter "hidden" section. When the user scrolls to the bottom of the second last section the viewport should snap with the bottom to the bottom of this section (same as the top of the last section). When the user tries to scroll through this one snap it should be only possible by overcoming a specific threshold.

I have visualized my issue for better understanding, I deeply hope this is possible with the current specification of snapping-points.

enter image description here


Solution

  • This is as far as I could get it using Alvaro Trigo's nice library pagePiling:

    http://codepen.io/anon/pen/NxaeZm

    The content is organized like so:

    <div id="pagepiling">
      <div class="section pp-scrollable" id="section1">
          <p>Content that scrolls normally</p>
        </div>
    
        <div class="section" id="hidden">
          <p>Not scrollable</p>
        </div>
    
        <div class="section pp-scrollable" id="section2">
          <p>Content that scrolls normally again</p>
        </div>
    
    </div>
    

    The middle section hijacks the scrolling, and afterwards you can continue scrolling towards the second section, which scrolls like a normal page again. I haven't been able to add a threshold to access the middle section. I leave it up to you there. Good luck!