I have a page with navigation to various sections. Each one provides an anchor tag for that page so someone can revisit the section easily. What I want is for the normal mechanism to work correctly but instead of jumping to the section (as per normal browser behavior) I want it to scroll there.
I have implemented the scrolling which works well I just dont know how to keep the hash URL as e.preventDefault()
stops this from occuring. If I remove this line then the page flashes before scrolling.
$(".navigation a").click(function(e){
$(".navigation a").removeClass("active");
$(this).addClass("active");
if ($(this).attr("href").substring(0,1) == "#"){
e.preventDefault();
$('html, body').animate({
scrollTop: $($(this).attr("href")).offset().top
}, 1000);
}
});