iPad Flicker on auto scroll using JQuery and Scrollto plugin

前端 未结 11 1614
情话喂你
情话喂你 2020-12-12 16:52

I am having a bit of a weird problem with iOS platform for a page i am developing. This is the page in question. When clicking any of the case study images, the page will

11条回答
  •  無奈伤痛
    2020-12-12 17:11

    If you're just scrolling the page vertically you can replace the entire jQuery scrollTo plugin with this simple line:

    $('html,body').animate({scrollTop: $("#scrollingTo").offset().top}, 1000, 'easeOutCubic');
    

    Personally I do something like this

    $('html,body').animate({scrollTop: $("#step-1").offset().top-15}, 1000, 'easeOutCubic',function(){
      //do stuff
    });
    

    I found that if I try to do other js work while it's scrolling it makes the browser crunch and the animation isn't smooth. But if you use the callback it'll scroll first, then do what you need.

    I put a -15 at the end of .top because I wanted to show the top edge of the div I was scrolling do, simply for aesthetic purposes. 1000 is the duration in milliseconds of the animation.

    Credit goes to the poster, animate, for the tip off.

提交回复
热议问题