I have a navigation bar that changes position to fixed when the user scrolls down past it and back to its original state when scrolling up, using a specific waypoint:
var $navbar = $('.navbar-default');
$navbar.waypoint(function(){
if ($('#navigation-bar').hasClass('navbar')){
$('#navigation-bar').toggleClass('navbar-fixed');
} else{
$('#navigation-bar').toggleClass('navbar');
}
}, { offset: '28%' });
While this functionality works well most of the time, there is an issue when the user scrolls past the waypoint and then refreshes the page. The navbar jumps back to its initial position, causing unexpected behavior if scrolled back up.
Is there a way to ensure everything on the screen remains in the same position after a page refresh?