【发布时间】:2015-04-01 17:53:03
【问题描述】:
Owl Carousel 2 中有没有办法让国王随机函数。我需要页面上的幻灯片随机加载。
在旧的 Owl Carousel 版本中,我是这样做的:
$(document).ready(function () {
//Sort random function
function random(owlSelector) {
owlSelector.children().sort(function () {
return Math.round(Math.random()) - 0.5;
}).each(function () {
$(this).appendTo(owlSelector);
});
}
$(".feedback").owlCarousel({
autoPlay: 5000,
slideSpeed: 200,
items: 1,
itemsDesktop: [1199, 1],
itemsDesktopSmall: [979, 1],
itemsTablet: [768, 1],
itemsMobile: [479, 1],
autoHeight: true,
//Call beforeInit callback, elem parameter point to $(".feedback")
beforeInit: function (elem) {
random(elem);
}
});
});
如何在 Owl Carousel 2 中以最佳方式做到这一点?
【问题讨论】:
标签: javascript jquery carousel owl-carousel