AnimatedResponsiveImageGrid
AnimatedResponsiveImageGrid copied to clipboard
Rotate the images in a random order.
Hi,
Thanks for the great plugin.
Is it possible to rotate the images in a random order (instead of in order currently), but also making sure 2 of the same images are never pulled at the same time?
Could you point me the code where i can make changes to achieve that? I just need to know how to edit the existing code to pull the images randomly.
Thanks,
+1 for this, and also a way to have the images load initially randomly.
Thanks to anyone who can help with this.
I just thought I'd put this code here for anyone interested. I managed to shuffle the order of the images using this code:
/*
* Shuffle jQuery array of elements - see Fisher-Yates algorithm
*/
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
shuffle(this.$items);
I put it in the _layout function in between this line
this.$items = this.$itemsCache.clone().appendTo( this.$list );
and this line
var $outItems = this.$items.filter( ':gt(' + ( this.showTotal - 1 ) + ')' ),