I have this randomize() function to randomize slides in Slick Slider. It works, but in Firefox it only works if there are more than two slides. Can anyone see why that is?
Js:
$.fn.randomize = function(selector) {
var $el = selector ? $(this).find(selector) : $(this).children(),
$pars = $el.parent();
$pars.each(function() {
$(this).children(selector).sort(function(chA, chB) {
if ($(chB).index() !== $(this).children(selector).length - 1) {
return Math.round(Math.random()) - 0.5;
}
}.bind(this)).detach().appendTo(this);
});
return this;
};
$('.slider').randomize().slick();
Html:
<div class="slider">
<div>
<img src="https://kenwheeler.github.io/slick/img/fonz1.png" />
</div>
<div>
<img src="https://kenwheeler.github.io/slick/img/fonz2.png" />
</div>
<! -- Uncomment to see it working in FF
<div>
<img src="https://kenwheeler.github.io/slick/img/fonz3.png" />
</div> -->
</div>