Good day
I’m editing a project that is using owl carousel, currently the carousel is in random mode, I want to sort it descending, here’s the code.
`self.carousel = function(){
setTimeout(function() {
//Sort random function
owl = $('#my_carousel');
owl.owlCarousel({
onInitialize: function (element) {
owl.children().sort(function () {
return Math.round(Math.random()) - 0.5;
}).each(function () {
$(this).appendTo(owl);
});
},
items: 1,
loop: true,
nav: false,
dots: true,
lazyLoad: true,
autoplay: true,
autoplayTimeout: 4000,
margin: 0,
responsiveClass: true
});
}, 100);
}`
I tried to find scripts in google but it does not work or the answer is different.
2
Answers
You can reverse the children before appending them
You can add one more attribute called direction:
direction:ltr,
or
direction:rtl,