From d9d65d59d19d9c64cf859d6972426c321d8c6fd9 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 30 Sep 2016 23:34:44 +0100 Subject: [PATCH] Fix timing window when scrolling search box results --- editor/js/ui/search.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/editor/js/ui/search.js b/editor/js/ui/search.js index 59c58f876..b7fd9ddbc 100644 --- a/editor/js/ui/search.js +++ b/editor/js/ui/search.js @@ -113,15 +113,17 @@ RED.search = (function() { } function ensureSelectedIsVisible() { var selectedEntry = searchResults.find("li.selected"); - var scrollWindow = searchResults.parent(); - var scrollHeight = scrollWindow.height(); - var scrollOffset = scrollWindow.scrollTop(); - var y = selectedEntry.position().top; - var h = selectedEntry.height(); - if (y+h > scrollHeight) { - scrollWindow.animate({scrollTop: '-='+(scrollHeight-(y+h)-10)},50); - } else if (y<0) { - scrollWindow.animate({scrollTop: '+='+(y-10)},50); + if (selectedEntry.length === 1) { + var scrollWindow = searchResults.parent(); + var scrollHeight = scrollWindow.height(); + var scrollOffset = scrollWindow.scrollTop(); + var y = selectedEntry.position().top; + var h = selectedEntry.height(); + if (y+h > scrollHeight) { + scrollWindow.animate({scrollTop: '-='+(scrollHeight-(y+h)-10)},50); + } else if (y<0) { + scrollWindow.animate({scrollTop: '+='+(y-10)},50); + } } }