From 4a9f92d8a13ba95d39afddde68a4569ffe064779 Mon Sep 17 00:00:00 2001 From: Joel Walters Date: Sat, 5 Oct 2013 22:27:53 -0700 Subject: [PATCH] Make random option more random --- responsiveslides.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/responsiveslides.js b/responsiveslides.js index fbc331a..8943a6a 100644 --- a/responsiveslides.js +++ b/responsiveslides.js @@ -129,12 +129,12 @@ // Random order if (settings.random) { - $slide.sort(function () { - return (Math.round(Math.random()) - 0.5); - }); - $this - .empty() - .append($slide); + // Shuffle all slides + while ($slide.length) { + $this.append($slide.splice(Math.floor(Math.random() * $slide.length), 1)); + } + // Get new children object + $slide = $this.children(); } // Add ID's to each slide