Reduce async loading from 0.25s to "when idle" and randomize load order
Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
parent
6e883c98fe
commit
78d667bdec
@ -323,6 +323,8 @@
|
||||
|
||||
start = 0;
|
||||
stop = this.thumbnails.length - 1;
|
||||
/* If there were visible thumbs, use the one from the middle as the starting
|
||||
* point to check visibility. Otherwise, binary-tree the entire image list */
|
||||
if (this.visibleThumbs.length) {
|
||||
index = this.visibleThumbs[this.visibleThumbs.length >> 1];
|
||||
} else {
|
||||
@ -390,6 +392,16 @@
|
||||
this.thumbnails[index].visible = false;
|
||||
}.bind(this));
|
||||
|
||||
/* 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) {
|
||||
var tmp = visible[i];
|
||||
visible[i] = visible[visible.length - 1];
|
||||
visible[visible.length - 1] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/* Turn on visibility for any item that is now visible */
|
||||
visible.forEach(function(index) {
|
||||
if (this.thumbnails[index].visible != true) {
|
||||
@ -398,7 +410,7 @@
|
||||
}.bind(this));
|
||||
|
||||
this.visibleThumbs = visible;
|
||||
}, 250);
|
||||
});
|
||||
},
|
||||
|
||||
findPhoto: function(photo) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user