tOOlmaRR / web-slideshow

a web application to display custom slideshows in a browser for locally-stored photos
0 stars 0 forks source link

Improve Randomization Logic #20

Closed tOOlmaRR closed 2 years ago

tOOlmaRR commented 2 years ago

When using the randomize feature, I find that I see a lot of the same slides over and over again. I thought that randomize only shuffled the indexes and continued the slideshow in a linear fashion, but if that was the case, I'd never get a repeat.

Revisit this logic and make sure that the indexes don't get reshuffled after every slide.

This should be applied to both the static and dynamic (DB-driven) slideshows.

tOOlmaRR commented 2 years ago

The issue was that I was randomly generating numbers to rebuild the array but not removing the chosen numbers from those available upon each subsequent random number generation.

I found a more optimized script to shuffle an existing array and implemented that.

tOOlmaRR commented 2 years ago

Also updated the randomize feature to stop randomization at the current slide so that the slideshow doesn't restart from the first slide