Navbar animation on scroll

Hi everyone!

I’ve been looking for a simple animation for the navbar that changes it (background color, border-bottom, etc.) as soon as the user scrolls from the top of the page, and resets when the user goes back to the top of the page. The issue I’ve seen is that when you scroll down and then refresh the page the animation doesn’t play leaving the navbar in it’s original state unless you scroll all the way back up. Sorry, I don’t have a link or anything to show at the moment.