disable dragging in specific element (Item) in “Owl carousel” - jquery

前端 未结 2 1693
南方客
南方客 2021-01-12 15:27

I use \"OWL Carousel\" jQuery plugin (http://www.owlgraphic.com/owlcarousel/) for in my small project.

I create small script that draggable via this plugin. now i wa

2条回答
  •  日久生厌
    2021-01-12 16:04

    I had the same problem and just figured it out:

    Add a class to the items you want to disable (i.e. "disable-owl-swipe") and stop event propagation on touchstart and mousedown, so the parents (the owl carousel wrappers) don't receive the event and therefore don't swipe.

    HTML:

    JS:

    $(".disable-owl-swipe").on("touchstart mousedown", function(e) {
        // Prevent carousel swipe
        e.stopPropagation();
    })
    

    Hope that helps!

提交回复
热议问题