Working on sort

Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
James Ketr 2018-09-05 09:02:13 -07:00
parent b7ff3ad1db
commit 4d9c3145fc

View File

@ -341,7 +341,11 @@
return; return;
} }
var index, length = this.thumbnails.length; var index, length = this.thumbnails.length - 1;
This needs to become a binary sort between min/max set by either visibleThumbs, or the full
array. 'index' adjustments then need to be done based on these values instead of on the full
array or the search can end up bouncing over the 'visible' items
if (this.visibleThumbs.length) { if (this.visibleThumbs.length) {
index = this.visibleThumbs[this.visibleThumbs.length >> 1]; index = this.visibleThumbs[this.visibleThumbs.length >> 1];
@ -383,6 +387,10 @@
visible.push(tmp++); visible.push(tmp++);
} }
visible.sort(function(a, b) {
return a - b;
});
var i; var i;
/* Remove 'visible' attribute from any thumbnail /* Remove 'visible' attribute from any thumbnail
* that was visible and is not in the new set of * that was visible and is not in the new set of
@ -390,12 +398,10 @@
this.visibleThumbs.forEach(function(index) { this.visibleThumbs.forEach(function(index) {
for (i = 0; i < visible.length; i++) { for (i = 0; i < visible.length; i++) {
if (visible[i] == index) { if (visible[i] == index) {
break; return;
} }
} }
if (i == visible.length) { this.thumbnails[index].visible = false;
this.thumbnails[index].visible = false;
}
}.bind(this)); }.bind(this));
/* Turn on visibility for any item that is now visible */ /* Turn on visibility for any item that is now visible */