I'm trying to create a page with 3 sections that change to the next one by giving scroll like a slideshow where each section is a frame. Like this site here: link
This is the .HTML:
<section id="apresentacao">
<h2>Section One</h2>
</section>
<section id="catergorias">
<h2>Section Two</h2>
</section>
<section id="estoque">
<h2>Section Three</h2>
</section>
No .js:
var sectionOne = $('section')[0].offsetTop;
var sectionTwo = $('section')[1].offsetTop;
var sectionThree = $('section')[2].offsetTop;
$(document).on("scroll", function() {
if (window.pageYOffset <= sectionTwo){
$("html, body").animate({scrollTop: sectionTwo},1000);
}
else if (window.pageYOffset <= sectionThree) {
$("html, body").animate({scrollTop: sectionThree},1000);
}
else if (window.pageYOffset >= sectionThree) {
$("html, body").animate({scrollTop: sectionTwo},1000);
}
})
In this case, it only recognizes the first scroll and then hangs in the second section. Does anyone know how I can solve it? Thanks