2
我已阅读了一堆关于此的讨论,但他们都没有为我解决这个问题。根据视口大小销毁并初始化猫头鹰传送带
我使用enquire.js做我视条件和我的代码如下:
var $slider = $('#home-farms-slider'),
sliderOptions = {
items: 1,
animateOut: 'fadeOut',
animateIn: 'fadeIn'
};
enquire.register("screen and (min-width: 1000px)", {
match : function() {
$slider.owlCarousel(sliderOptions);
},
unmatch : function() {
$slider.trigger('destroy.owl.carousel');
}
});
一切工作按预期只是当destroy
被触发,我的控制台引发此错误:
Uncaught TypeError: Cannot read property '_onResize' of null
owl.carousel.min.js?ver=2.0.0:1
e.onThrottledResize
owl.carousel.min.js?ver=2.0.0:1
m.isFunction.e
jquery.js?ver=1.11.1:2
发生这种情况时,当我的条件匹配时,滑块将不再初始化。我不确定到底发生了什么。
更新9/15:
我碰到这个问题在GitHub上,也做了同样的我的滑块:
https://github.com/OwlFonk/OwlCarousel2/issues/460
我现在能够破坏并重新初始化OwlCarousel因为类和包装都不见了。但是,我仍然收到该控制台错误。每当视口调整大小时都会重复该错误,所以尽管我的滑块行为正常,但这并不理想。任何帮助,为什么我得到这个错误将是真棒!
是的!这阻止了错误。谢谢! – 2014-10-14 02:28:56
这是测试版2中的一个错误 - 更新至测试版3时,问题得到修复 - 请参阅:https://github.com/smashingboxes/OwlCarousel2/commit/2064682082e5127620b07f5d4d97a8e883e3d440 – 2015-11-30 11:33:35