Here is the deal. I’m using a plugin called backstretch wich fullscreen my background images and making a slideshow of it.
This is what I have for now (website of the plugin).
Now, I want the images be random each time. Say I have 3 images, it would be like:
2, 3, 1
3, 1, 2
1, 2, 3
1, 3, 2
In a line this would be: 2, 3, 1, 3, 1, 2, 1, 2, 3, 1, 3, 2
Note: images must avoid repeating themself like: 2, 3, 1, 1, 2, 3
Anyone?
Use
math.Random();to provide a random index from your array place this within a while loop and do it till you get a different number. ie.EDIT:
To start with a random image use the random method before you call backstretch
Your fiddle
EDIT 2:
After discussing with the OP requirements (in comments), they required a not entirely random slider. It was required to ensure all indexes were used before selecting any of them again then when empty then reset.
By populating a list of indexes into a separate array we can then remove from the array as we use them until empty and then repopulate, We also mantain the previous index so that even on resetting that a image wouldn’t repeat. The final result here