This code, in principle, is working, but, great but, it does not work as it should.
function linksBinder() { $('a[href^="#"]').bind( 'click.smoothscroll', function (e) { e.preventDefault(); var target = this.hash, $target = $(target) ; $('#pMainWrapper').stop().animate({'scrollTop': $target.offset().top},2000,'swing', function () { window.location.hash = target; var sidebar = $(".pMainSidebar").hasClass("menuisopen"); if (sidebar) { $(".pMainSidebar").removeClass("menuisopen"); // Тут секция с ссылками $(".pMainMobileMenu").removeClass("menuopen"); } } ); } ); } MainWrapper is a div with basic content (yes, I know that it’s a non-standard solution, but it’s necessary =]).
Scrolling takes place in a div and always scrolls up, and then returns where it was indicated, sharply. And you need to return to any element with any scrolling. For example, scrolled to 100PX, you need to scroll down to some element. Either scrolled to the very end of the diva, you need to scroll up to the element.
That is, you need a position validator or something? Will you show?