From 59bbde7e7d584523306bbe9e67e25e6f0d7303f9 Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Tue, 4 Sep 2018 20:12:07 -0700 Subject: [PATCH] Escape on stuck code Signed-off-by: James Ketrenos --- frontend/src/ketr-photos/ketr-photos.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/ketr-photos/ketr-photos.html b/frontend/src/ketr-photos/ketr-photos.html index eb9fd64..0779551 100755 --- a/frontend/src/ketr-photos/ketr-photos.html +++ b/frontend/src/ketr-photos/ketr-photos.html @@ -350,18 +350,19 @@ } var pos = this.checkPosition(index), last = -1; - while (pos != 0 && last != pos) { + while (pos != 0 && last != index) { + last = index; /* safety escape in case the DOM changed and nothing matches */ + if (pos == +1) { /* Checked item was too low on the page, so look closer to start */ index = index >> 1; } else { /* Checked item was too high on the page, so look farther */ index += (length - index) >> 1; } - last = index; /* safety escape in case the DOM changed and nothing matches */ pos = this.checkPosition(index); } - if (pos == last) { + if (pos != 0) { console.log("DOM changed or viewport changed and search would never exit; re-scheduling check") //this.triggerVisibilityChecks(); return;