Reputation: 9417
I have made an Accordion Menu like what have been explained here. The problem is that when you clicking on the menu items, browser will try to jump (and scrolling) to the target
to be sure that the target is visible in the view port. Is there any solution to prevent the jump, except something like this?
$("a[href^=#]").on("click", function(e) {
e.preventDefault();
history.pushState({}, "", this.href);
});
js source: Fighting the jump
Upvotes: 2
Views: 193
Reputation: 448
There is no other way than using JavaScript. You could also listen to the hashchange event, save the actual scroll position at the time of the event firing and jump back to it after the event. But those are the only possible solutions one could think of.
Upvotes: 1