owlCarousel 在页面调整大小时不计算手风琴的高度

owlCarousel not calculating height in accordion on page resize

我正在手风琴中使用 owl旋转木马。一切都很好,直到我调整 window.

的大小

调整大小后,如果手风琴已经打开,它看起来很完美,但如果在调整大小时关闭,轮播高度变为 0。

我尝试使用 .refres() 轮播的 .refres() 方法,但没有成功。

我找到了解决方案 here

ses & improvised by tofumedia

给出了解决方案

正如引用的那样:

OWL start for the JS Accordion, and need a resize refresh

JS:

$('.owl-carousel').owlCarousel({
    margin: 0,
    responsiveClass: true,
    nav: false,
    dots: true,
    items: 1,
    responsive: {
        0: {
            items: 1
        },
        600: {
            items: 1
        },
        1000: {
            items: 1
        }
    }
});

$("#accordion").accordion({
    heightStyle: "content",
    header: ".accordionHeadline",
    collapsible: true,
    active: 0,
    beforeActivate: function (event, ui) {
        window.dispatchEvent(new Event('resize'));
    }
});

或者更靠谱的支持IE的方案:

$("a[data-toggle='tab']").on('shown', function () {
    var evt = document.createEvent('UIEvents');
    evt.initUIEvent('resize', true, false,window,0);
    window.dispatchEvent(evt);
});