I have the following structure:
<body>
<div id="first-div">
<div id="second-div"></div>
<div id="third-div"></div>
</div>
</body>
#first-div {
height: 100%;
}
#second-div, #third-div {
display: none;
}
Upon detecting the first scroll down event I need the #second-div to be displayed, If a second scroll down event is detected, I need #third-div to be displayed and #second-div to be hidden. My problem is: a single scroll down on the touchpad might trigger multiple events thus showing the #second-div and #third-div immediately.
$(body).on('DOMMouseScroll mousewheel', function (event) {
if (event.originalEvent.detail > 0 || event.originalEvent.wheelDelta < 0) {
//scroll down
console.log('Down');
} else {
//scroll up
console.log('Up');
}
//prevent page fom scrolling
return false;
});
How Can I detect the scroll down event, stop the scroll event and show #second-div. Then detect another scroll down event, stop the scroll event and hide #second-div and show #third-div?
Also, Afterwards, I detect the scroll up event, stop the scroll event and hide #third-div and show #second-div. Then detect another scroll up event, stop the scroll event and hide #second-div?
Thank you.