diff --git a/frontend/src/ketr-photos/ketr-photos.html b/frontend/src/ketr-photos/ketr-photos.html index 0779551..199d6b5 100755 --- a/frontend/src/ketr-photos/ketr-photos.html +++ b/frontend/src/ketr-photos/ketr-photos.html @@ -341,7 +341,11 @@ 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) { index = this.visibleThumbs[this.visibleThumbs.length >> 1]; @@ -383,6 +387,10 @@ visible.push(tmp++); } + visible.sort(function(a, b) { + return a - b; + }); + var i; /* Remove 'visible' attribute from any thumbnail * that was visible and is not in the new set of @@ -390,12 +398,10 @@ this.visibleThumbs.forEach(function(index) { for (i = 0; i < visible.length; i++) { if (visible[i] == index) { - break; + return; } } - if (i == visible.length) { - this.thumbnails[index].visible = false; - } + this.thumbnails[index].visible = false; }.bind(this)); /* Turn on visibility for any item that is now visible */