The trick is possible by making sections of the page
position: fixed
and then setting a height for the document
body
equal to the combined height of the page sections. When the
window
is scrolled down we
move our page sections upwards out of the viewport to reveal the content underneath. The opposite being that, when the
window
is scrolled up, we bring our sections back down into view in the same order in which they left(
dictated by the DOM structure
).
doormat.js
and
doormat.css
in your page.
Create your DOM structure. The structure needs to be a container with the classname
dm
. Child elements need to have the classname
dm__pnl
.
ol
and
ul
are appropriate elements.
<ol class="dm">
<li class="dm__pnl">Awesome</li>
<li class="dm__pnl">Site</li>
<li class="dm__pnl">Content</li>
</ol>
Invoke the
Doormat
function passing in desired options(
refer to
docs
). For example;
var myDoormat = new Doormat();
var myDoormat = new Doormat({
scrollBuffer : 15,
snapThreshold: 15,
snapDuration : 250
});
For more, see the repo !