Conditionally block scrolling/touchmove event in mobile safari

后端 未结 6 1541
暗喜
暗喜 2021-02-03 13:46

iOS 5 now allows native overflow: scroll support.

What I\'d like to do is disable the touchmove event for everything except elements that have the \'scrolla

6条回答
  •  抹茶落季
    2021-02-03 14:11

    If you write this in jquery document.ready event it will work.

    $('body').on('touchmove', function (e) {
      if ($(e.target).closest("your_scrollable_div_selector").length == 0)
        e.preventDefault();
    });
    

提交回复
热议问题