Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 582
zoma Avatar asked Jan 14 '16 10:01

zoma


People also ask

What is snap scrolling?

CSS Scroll Snap is a module of CSS that introduces scroll snap positions, which enforce the scroll positions that a scroll container's scrollport may end at after a scrolling operation has completed.

What is scroll padding?

CSS Demo: scroll-padding This allows the author to exclude regions of the scrollport that are obscured by other content (such as fixed-positioned toolbars or sidebars), or to put more breathing room between a targeted element and the edges of the scrollport.

Can I use CSS scroll snap?

CSS Scroll Snap is supported in all major browsers. A previous version of the specification was implemented in some browsers, and may appear in tutorials and articles. If material includes the deprecated scroll-snap-points-x and scroll-snap-points-y properties, it should be considered outdated.


Video Answer


1 Answers

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!

like image 152
fnune Avatar answered Oct 23 '22 15:10

fnune