1
I’m trying to create a page with 3 sections that change to the next by scrolling as if it were a slideshow where each section is a frame. As in this site here: http://www.legworkstudio.com/
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 to fix it? Thanks
You can do something VERY MUCH next to this only with CSS and HTML, if it is of interest I can make answer with an example for you to see if it serves you.
– hugocsl