I'm trying to figure out a way to have a sort of slideshow mechanic where scrolling hides and shows specific DIVs, and after the final DIV has been reached the rest of the content becomes free scrolling. But this seems to be something way beyond my basic understanding of jQuery.
I have this JSFiddle set up for what I have right now, but it only works for the transition between the first and second DIV: https://jsfiddle.net/psvg5b8k/
I'm currently using IDs to target the DIVs, but ideally the script should automatically run through all of the divs that have the class ".bd__bg" assigned (in order) before showing the content of id="bd" with free scrolling.
$(document).ready(function() {
var bdBG = $('.bd__bg'),
bd = $('#bd');
$(bdBG).each(function() {
$(this).hide();
});
// $(bd).hide();
$('#01').show();
});
$(window).scroll(function() {
if ($(this).scrollTop() > 200) {
$('#01').fadeOut();
$('#02').fadeIn();
} else if ($(this).scrollTop() > 400) {
$('#02').fadeOut();
$('#03').fadeIn();
} else if ($(this).scrollTop() > 600) {
$('#03').fadeOut();
$('#04').fadeIn();
} else {
$('#04').fadeOut();
// $(bd).fadeIn();
}
});
<div class="grid">
<div class="grid__row bd__bg" id="01">
</div>
</div>
<div class="grid">
<div class="grid__row bd__bg" id="02">
</div>
</div>
<div class="grid">
<div class="grid__row bd__bg" id="03">
</div>
</div>
<div class="grid">
<div class="grid__row bd__bg" id="04">
</div>
</div>
<div class="grid">
<div class="grid__row" id="bd">
</div>
</div>