From a99db36578bd844217889fec905f8efde0030729 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Tue, 19 May 2020 23:51:00 +0000 Subject: [PATCH] Desktop: Fixed two way scrolling issue in Markdown editor --- ElectronClient/gui/NoteEditor/NoteEditor.tsx | 2 +- ElectronClient/gui/note-viewer/index.html | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ElectronClient/gui/NoteEditor/NoteEditor.tsx b/ElectronClient/gui/NoteEditor/NoteEditor.tsx index a2e877bba4..47f3246e27 100644 --- a/ElectronClient/gui/NoteEditor/NoteEditor.tsx +++ b/ElectronClient/gui/NoteEditor/NoteEditor.tsx @@ -85,7 +85,7 @@ function NoteEditor(props: NoteEditorProps) { function scheduleSaveNote(formNote: FormNote) { if (!formNote.saveActionQueue) throw new Error('saveActionQueue is not set!!'); // Sanity check - reg.logger().debug('Scheduling...', formNote); + // reg.logger().debug('Scheduling...', formNote); const makeAction = (formNote: FormNote) => { return async function() { diff --git a/ElectronClient/gui/note-viewer/index.html b/ElectronClient/gui/note-viewer/index.html index b0f198ccc7..327a2dad64 100644 --- a/ElectronClient/gui/note-viewer/index.html +++ b/ElectronClient/gui/note-viewer/index.html @@ -82,6 +82,12 @@ let percentScroll_ = 0; let checkScrollIID_ = null; + // This variable provides a way to skip scroll events for a certain duration. + // In general, it should be set whenever the scroll value is set explicitely (programmatically) + // so as to differentiate scroll events generated by the user (when scrolling the view) and those + // generated by the application. + let lastScrollEventTime = 0; + function setPercentScroll(percent) { percentScroll_ = percent; contentElement.scrollTop = percentScroll_ * maxScrollTop(); @@ -92,6 +98,7 @@ } function restorePercentScroll() { + lastScrollEventTime = Date.now(); setPercentScroll(percentScroll_); } @@ -206,7 +213,6 @@ }, 100); } - let lastScrollEventTime = 0; ipc.setPercentScroll = (event) => { const percent = event.percent;