From 41f32ae341de51cf8caf35c4a4d3ab2410a2741b Mon Sep 17 00:00:00 2001 From: rlx Date: Fri, 1 Feb 2019 15:19:34 +0530 Subject: [PATCH] fix scroll-to-selected --- txt.js/txt.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/txt.js/txt.js b/txt.js/txt.js index bf90f9d..c92ca06 100644 --- a/txt.js/txt.js +++ b/txt.js/txt.js @@ -500,9 +500,12 @@ txtjs.selectNote = function(id, trigger) { elements.forEach(function(element) { element.classList.add('selected') }) - // FIXME: SCROLL - // elements[0].scrollIntoView() - // window.scrollTo(0, elements[0].offsetTop) + for (let i = 0; i < elements.length; i++) { + if (!elements[i].parentNode.id.includes('scroll')) { + elements[i].scrollIntoViewIfNeeded() + break + } + } } if (trigger !== false) { txtjs.postMessage('selectNote', {id: id})