I have a script which will make a simple slider with buttons to navigate.
Now I need to make this slider controllable with scrolling.
When the user scrolls down, focus will be moved to the next slider, and also in reverse.
Buttons will be available too. So, there will be 2 options to control it. With buttons next and back and also with scrolling down or up.
Is there any option of how to do it in the easiest way?
var lottieone = document.getElementById('lottieone');
var lottietwo = document.getElementById('lottietwo');
var lottiethree = document.getElementById('lottiethree');
var lottiefour = document.getElementById('lottiefour');
$('#lottieone').show();
$('#lottietwo').hide();
$('#lottiethree').hide();
$('#lottiefour').hide();
function missionsSlide() {
$('#lottieone').hide();
$('#lottietwo').show();
$('#lottiethree').hide();
$('#lottiefour').hide();
}
function missionsSlideBacc() {
$('#lottieone').hide();
$('#lottietwo').show();
$('#lottiethree').hide();
$('#lottiefour').hide();
}
function researchSlide() {
$('#lottieone').hide();
$('#lottietwo').hide();
$('#lottiethree').show();
$('#lottiefour').hide();
}
function educationSlide() {
$('#lottieone').hide();
$('#lottietwo').hide();
$('#lottiethree').hide();
$('#lottiefour').show();
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section class="slider">
<div id="lottieone" class="lottieSlide">
<div class="content">
<button onclick="missionsSlide()">HOME</button>
</div>
</div>
<div id="lottietwo" class="lottieSlide mainSliders">
<div class="content">
<h1>MISSIONS</h1>
<button onclick="researchSlide()">Next</button>
</div>
</div>
<div id="lottiethree" class="lottieSlide mainSliders">
<div class="content">
<h1>RESEARCH</h1>
<button onclick="missionsSlideBacc()">Back</button>
<button onclick="educationSlide()">Next</button>
</div>
</div>
<div id="lottiefour" class="lottieSlide mainSliders">
<div class="content">
<h1>EDUCATION</h1>
<button onclick="researchSlide()">Back</button>
</div>
</div>
</section>