From dba5c40f6adaef75afceb605ff452e8b4eeb57c4 Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Thu, 6 Sep 2018 20:21:49 -0700 Subject: [PATCH] Reduce async loading from 0.25s to "when idle" and randomize load order Signed-off-by: James Ketrenos --- frontend/src/ketr-photos/ketr-photos.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/ketr-photos/ketr-photos.html b/frontend/src/ketr-photos/ketr-photos.html index e263a9e..6b0634e 100755 --- a/frontend/src/ketr-photos/ketr-photos.html +++ b/frontend/src/ketr-photos/ketr-photos.html @@ -394,14 +394,14 @@ /* Randomly index the visible array, keeping the center * in the middle. This makes the loading look more organic. */ - for (var i = 0; i < visible.length >> 1; i++) { - if (Math.rand() > 0.5) { + for (var i = 0, j = visible.length - 1; i != j; i++, j--) { + if (Math.random() > 0.5) { var tmp = visible[i]; - visible[i] = visible[visible.length - 1]; - visible[visible.length - 1] = tmp; + visible[i] = visible[j]; + visible[j] = tmp; } } - + /* Turn on visibility for any item that is now visible */ visible.forEach(function(index) { if (this.thumbnails[index].visible != true) {