Unable to preventDefault inside passive event listener

前端 未结 6 839
终归单人心
终归单人心 2020-11-29 06:13

I\'m using Framework7 sortable list and it works well, just that it doesn\'t trigger an event when the list is changed.

So I\'m trying a few built-in events:

<
相关标签:
6条回答
  • 2020-11-29 06:39

    See this blog post. If you call preventDefault on every touchstart then you should also have a CSS rule to disable touch scrolling like

    .sortable-handler {
      touch-action: none;
    }
    
    0 讨论(0)
  • 2020-11-29 06:40

    I am getting this issue when using owl carousal and scrolling the images.

    So get solved just adding below CSS in your page.

    .owl-carousel {
    -ms-touch-action: pan-y;
    touch-action: pan-y;
    }
    

    or

    .owl-carousel {
    -ms-touch-action: none;
    touch-action: none;
    }
    
    0 讨论(0)
  • 2020-11-29 06:46

    To handle sortable list in Framework7 when user release currently sorting element in new position, you can use this code:

      $$('li').on('sortable:sort',function(event){
        alert("From " + event.detail.startIndex + " to " + event.detail.newIndex);
      });
    

    Fiddle : https://jsfiddle.net/0zf5w4y7/

    0 讨论(0)
  • 2020-11-29 06:46

    For me

    document.addEventListener("mousewheel", this.mousewheel.bind(this), { passive: false });
    

    did the trick (the { passive: false } part).

    0 讨论(0)
  • 2020-11-29 06:52

    In plain JS add { passive: false } as third argument

    document.addEventListener('wheel', function(e) {
        e.preventDefault();
        doStuff(e);
    }, { passive: false });
    
    0 讨论(0)
  • 2020-11-29 07:04

    To still be able to scroll this worked for me

    if (e.changedTouches.length > 1) e.preventDefault();
    
    0 讨论(0)
提交回复
热议问题