JQuery scrollLeft not working

I just launched http://elliewauters.com and have a little problem that I would like to fix, the site uses a lot of animated horizontal scrolls to go from one page to another, but when updating most browsers remember the scroll position and return to where I was before, I do not want this. Try going to the About page, and then updating. You will see that the logo and menu are in the middle of the page, since they are when you first got to the site.

I would like to help with either of two things:

  • In reset, scroll position back to 0.0 on the OR update page
  • To move the logo and menu at the top if scrollLeft is greater than 1.

I tried to use to $(window).scrollLeft(0);no avail and

scrollLeft = $(window).scrollLeft();
console.log(scrollLeft)
if (scrollLeft>1) {
    $('#header').addClass('notLeft').css('top','0%');
} else {
    $('#header').addClass('left').css('top','25%');
}

, -, , , , ?

+3
3

Firefox - console.log(scrollLeft), . , , , IE? , $(window), $(document). :

scrollLeft = $(document).scrollLeft();
+6

, , .scrollLeft() jQuery Android jQuery 1.9.1 ( 2013 .). :

window.scrollTo(x, y);

, Android.

+2
$("#el").animate({ scrollLeft:110 }, "fast");
+1

Source: https://habr.com/ru/post/1769439/


All Articles