Hello, good morning, I would like to know if anyone has already seen or has already implemented a progress bar when scrolling the page. a bar that is fixed below with a forward button
more or less this ..
var sections = $('.panelSection');
console.log(sections);
var i =0;
var scrolto = 0;
function next(){
if(i == 0){
$('.prev-section').show();
}
if(i < sections.length -1){
i++;
$('html, body').animate({
scrollTop: sections[i].offsetTop
}, 2000);
}
}
function prev(){
if(i == sections.length -1){
$('.next-section').show();
}
if(i > 0){
i--;
$('html, body').animate({
scrollTop: sections[i].offsetTop
}, 2000);
}
}
$('html').keydown(function(e){
if(e.which == '38'){
prev();
}
if(e.which == '40'){
next();
}
});
$('.next-section').click(function(e){
e.preventDefault();
next();
});
$('.prev-section').click(function(e){
e.preventDefault();
prev();
});
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script><scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<style>
section{height: 100vh;text-align: center; font-size: 30pt}
</style>
<section class="panelSection">
INICIO
</section>
<section class="panelSection">
TOPICO 1
</section>
<section class="panelSection">
TOPICO 2
</section>
<footer>
<div class="navbar navbar-default navbar-fixed-bottom">
<div class="container-fluid">
<div class="navbar-collapse collapse" id="footer-body">
<ul class="nav navbar-nav pull-right">
<li><a href="#" class="next-section">Next Section</a></li>
</ul>
</div>
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#footer-body">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<li><a href="#" class="next-section">Next Section</a></li>
</button>
</div>
</div>
</div>
</footer>