Is there a way to use jQuery for animating the navigation bar, making it change color as you scroll? I am looking to create a navigation bar that has a background-color of rgba(51, 51, 51, 0.3) when at the top of the page, and rgba(255, 255, 255, 1) when scrolled 600 pixels down.
I am aware that this can be achieved with code like:
$(window).bind('scroll', function() {
if ($(window).scrollTop() > 600) {
$('.navbar-container-fixed').addClass('white');
}
else if ($(window).scrollTop() < 600) {
$('.navbar-container-fixed').removeClass('white');
}
});
However, this method changes the color abruptly without any animation. My intention is to have a gradual color transition, where the background color slowly evolves to white as the user scrolls down the page. For example:
0 px from top: rgba(51, 51, 51, 0.3)
100px from top: rgba(85, 85, 85, 0.4167)
200px from top: rgba(119, 119, 119, 5.334)
and so forth.