How to prevent pull-down-to-refresh of mobile chrome

后端 未结 4 1063
我在风中等你
我在风中等你 2020-12-09 15:15

I want to prevent pull-down-to-refresh of mobile chrome(especially iOS chrome). My web application has vertical panning event with device-width and device-height viewport, b

4条回答
  •  一个人的身影
    2020-12-09 15:56

    For latest versions of Chrome:

    html,
    body {
        overscroll-behavior-y: contain;
    }
    

    Old solution:

    Since mobile Chrome >= 56 event listeners are passive by default and passive event listeners can't prevent defaults anymore. See here You have to use active event listeners instead like so:

    document.addEventListener('touchstart', touchstartHandler, {passive: false});
    document.addEventListener('touchmove', touchmoveHandler, {passive: false});
    

提交回复
热议问题