CollectionBuilder / collectionbuilder-contentdm

CollectionBuilder-CONTENTdm digital collection "Skin" generator (deprecated).
MIT License
9 stars 4 forks source link

shuffle / randomize browse js cards #7

Closed evanwill closed 5 years ago

evanwill commented 5 years ago

add shuffle function:

/* Fisher-Yates shuffle https://bost.ocks.org/mike/shuffle/ */
  function shuffle(array) {
      var m = array.length, t, i;
      while (m) {
      i = Math.floor(Math.random() * m--);
      t = array[m];
      array[m] = array[i];
      array[i] = t;
      }
      return array;
  }

then add shuffle(items); somewhere.

evanwill commented 5 years ago

@dcnb @owikle should it be:

  1. shuffle the array one time on load (each time you visit browse it is different, but it doesn't change while you are searching, clicking buttons on the page)
  2. re-shuffle everytime it adds cards (each time you search or click something it reshuffles)
  3. shuffle is a button (maybe next to item count?) that you click to re-shuffle the current set of cards/array, making it a user option.
evanwill commented 5 years ago

p.s. I don't think there is any noticeable performance difference shuffling or not

evanwill commented 5 years ago

consensus on option 1. now added!