I have this piece of javascript that adjust the navigaton bar transparency while scrolling; everything works fine when scrolling slowly but when the scrolling speed is fast it seems it is not called and the navbar transparency is not set.
Any clue? I use Bootstrap 4.
$(document).ready(function() {
// Set original transparency
$("#navbar").css("background-color", "#1c447a00");
// Bind to scroll
$(window).scroll(function(){
// Fade navbar
var opacity = $(this).scrollTop() * 3;
if(opacity <= 0.2) {
opacity = 0;
} else if(opacity > 255) {
opacity = 255;
}
$("#navbar").css("background-color", "#1c447a" + opacity.toString(16));
});
});