设置后更改owl carousel 2选项? [英] change owl carousel 2 options after setup?
本文介绍了设置后更改owl carousel 2选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在设置更具体的更改owl carousel 2选项。
I'm searching for change owl carousel 2 options after setup more specifically.
我正在搜索禁用拖动元素的父元素的方法,如下所示:
I am searching a way to disable drag of parent element of the drag element like this:
$('#carousel').on('drag.owl.carousel', function(event) {
$('.carousel').on('drag.owl.carousel', function(event) {
//disable drag
})
})
$('#carousel').on('dragged.owl.carousel', function(event) {
$('.carousel').on('dragged.owl.carousel', function(event) {
//enable drag
})
})
推荐答案
不要试图通过挂钩拖动事件来禁用拖动,最好使用 owl.reinit ()
函数,以及 touchDrag
和 mouseDrag
选项。例如,如果你有一个轮播 #carousel
:
Rather than try to disable the drag via hooking into the drag events, it would be better to use the owl.reinit()
function, along with the touchDrag
and mouseDrag
options. For instance, if you had a carousel #carousel
:
var $carousel = $('#carousel');
var owl = $carousel.data('owlCarousel'); # Your DOM element gets an 'owlCarousel' data property containing the Owl object.
owl.reinit({touchDrag: false, mouseDrag: false;});
虽然该方法名为 reinit
,但它不会删除任何先前设置的选项。
Although the method is named reinit
, it won't blank any of your previously-set options.
这篇关于设置后更改owl carousel 2选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文