【问题标题】:owl carousel - count inactive slidesowl carousel - 计算非活动幻灯片
【发布时间】:2017-09-20 11:29:22
【问题描述】:

我必须为看不见的盒子做柜台之类的东西。如果我滑动到结束,计数器应该是'0'。如果它刚刚开始的计数器应该只显示我仍然没有看到的那些(例如它应该是 3)

我做了类似的东西,但是里面有错误,无法处理

jquery 或 javascript https://jsbin.com/vifakamaha/edit?html,js,output

 var owl = $('.owl-carousel');
owl.owlCarousel({
        items: 4,
        responsive: {
            0 : {
                items: 1
            },
            500 : {
                items: 2
            },
            991 : {
                items: 3 
            },
            1200 : {
                items: 4
            },

        }
    });

    var nextAfterActive = $(".owl item.active").last().nextAll().length;
    $('.count').html(nextAfterActive);

owl.on('changed.owl.carousel', function(event) {
    var nextAfterActive = $(".owl-item.active").last().nextAll().length;
    $('.count').html(nextAfterActive);
})

【问题讨论】:

  • 响应式现在已经不重要了。我知道如何编辑帖子

标签: javascript jquery owl-carousel


【解决方案1】:

我认为您使用的事件不正确,来自 owl carousel's API docs,我认为您应该使用 dragged 事件,例如:

owl.on('dragged.owl.carousel', function(event) {
    var nextAfterActive = $(".owl-item.active").last().nextAll().length;
    $('.count').html(nextAfterActive);
})

https://jsbin.com/tejilacace/1/edit?html,js,output

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-04
    • 1970-01-01
    相关资源
    最近更新 更多