Mobile Safari bug on fixed positioned button after scrollTop programmatically changed…?

后端 未结 11 2214
别跟我提以往
别跟我提以往 2020-11-28 04:10

I\'m just about done a webpage but there is one bug in Mobile Safari (iPhone and iPad iOS 5.0.1) with two buttons that are fixed to the upper and lower right corners..

11条回答
  •  孤独总比滥情好
    2020-11-28 04:49

    Here is my solution if like me, none of the previous solution is working for you.

    The trick is:

    • Do your scroll (Animate or scrollTo, etc.)
    • Just after your scroll, position:absolute your fixed elements
    • On the 'touchmove' event, restore the position:fixed

    Here an example:

      $('body').animate({
           scrollTop: newPos}, 1000, 'jswing', function () {
              $('header').css({position:'absolute', top:newPos});
      });
    
      $(document).bind('touchmove',function(){
           $('header').css({position:'fixed', top:'0px'});
      });   
    

    I used the same trick for sticky footer and other floating fixed elements.

提交回复
热议问题