【问题标题】:owl carousel custom navigation trigger parent eventowl carousel 自定义导航触发父事件
【发布时间】:2016-07-22 10:40:15
【问题描述】:

我正在使用带有同步滑块的 Owl Carousel。 我正在使用触发 owl-next 功能的自定义导航。

我的问题是,在底部幻灯片中触发“下一张”幻灯片是有效的,但不是第二个按钮,它应该触发父滑块。

到目前为止我的代码:

$(".konfig-slide-top").owlCarousel({
        navigation: false,
        pagination: false,
        slideSpeed: 1000,
        paginationSpeed: 500,
        paginationNumbers: false,
        singleItem: true,
        autoPlay: false,
        autoHeight:false,
        animateIn: 'slideIn',
        animateOut: 'slideOut',
        afterAction : syncPositionnew,
        responsiveRefreshRate : 200,
        afterMove: afterActionnew
    });

var owl = $(".konfig-slide-inner");

    owl.owlCarousel({
        items: 1,
        pagination: false,
        navigation: false,

        slideSpeed: 800,
        paginationSpeed: 700,
        animateIn: 'slideIn',
        animateOut: 'slideOut',
        autoHeight: true,
        responsiveRefreshRate : 100,
        mouseDrag: false,
        loop: false,
        afterInit : function(el){
        el.find(".owl-item").eq(0).addClass("syncednew2");
        }
    });

//slide inner slider        
    $('.next-inner').click(function() {
        owl.trigger('owl.next');
    });

    // slide parent slider
    $('.next-top').click(function() {
        var top = $(".konfig-slide-top").find('owl-controls');
        top.trigger('owl.next');
    });

父滑块的另一个可能的解决方案是:

var top = $(".konfig-slide-top");

    // slide parent slider
    $('.next-top').click(function() {
        top.trigger('owl.next');
    });

我似乎错过了什么。有谁知道吗?

【问题讨论】:

    标签: jquery


    【解决方案1】:

    解决方案非常简单。嗯,好像是这样。

    var top = $(".konfig-slide-top");
    
        // slide parent slider
        $('.next-top').click(function() {
            top.trigger('owl.next');
            return false;
        });
    

    添加return false;使代码工作。 但我不太明白为什么。 :/ 谁能给我解释一下?

    【讨论】:

      猜你喜欢
      • 2015-09-22
      • 1970-01-01
      • 2020-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-29
      • 1970-01-01
      相关资源
      最近更新 更多