Conditionally block scrolling/touchmove event in mobile safari

后端 未结 6 1618
暗喜
暗喜 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:30

    We can use the touchstart event instead of touchmove event. Under One Finger Events it says that no events are sent during a pan, so touchmove may be too late.

    I added the listener to document, not body.

    document.ontouchstart = function(e){ 
      e.preventDefault(); 
    }
    

提交回复
热议问题