1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Fix timing window when scrolling search box results

This commit is contained in:
Nick O'Leary 2016-09-30 23:34:44 +01:00
parent aad29e4487
commit d9d65d59d1

View File

@ -113,15 +113,17 @@ RED.search = (function() {
} }
function ensureSelectedIsVisible() { function ensureSelectedIsVisible() {
var selectedEntry = searchResults.find("li.selected"); var selectedEntry = searchResults.find("li.selected");
var scrollWindow = searchResults.parent(); if (selectedEntry.length === 1) {
var scrollHeight = scrollWindow.height(); var scrollWindow = searchResults.parent();
var scrollOffset = scrollWindow.scrollTop(); var scrollHeight = scrollWindow.height();
var y = selectedEntry.position().top; var scrollOffset = scrollWindow.scrollTop();
var h = selectedEntry.height(); var y = selectedEntry.position().top;
if (y+h > scrollHeight) { var h = selectedEntry.height();
scrollWindow.animate({scrollTop: '-='+(scrollHeight-(y+h)-10)},50); if (y+h > scrollHeight) {
} else if (y<0) { scrollWindow.animate({scrollTop: '-='+(scrollHeight-(y+h)-10)},50);
scrollWindow.animate({scrollTop: '+='+(y-10)},50); } else if (y<0) {
scrollWindow.animate({scrollTop: '+='+(y-10)},50);
}
} }
} }