1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| $(document).on("scroll", function () {
var pixels = $(document).scrollTop();
var pageWidth = $('header').width() ;
var pageHeight = $(document).height() - $(window).height();
var progress = 100 * pixels / pageHeight;
let coef = pageWidth / 291 - 337 / 291; // calcul de la largeur final en fonction de la largeur de la page
var progress2 = 0.96 * progress * coef;
var progress3 = 2.9 * progress * coef;
console.log(pageWidth);
$("#progressbar").attr('value', progress);
$("#space2").css('margin-left', progress2 + '%');
$("#space3").css('margin-left', progress3 + '%');
}); |
Partager