From 1d46d9f657a07240e27a3b05053cf9ac12e7d096 Mon Sep 17 00:00:00 2001 From: Kenichi Kobayashi Date: Sat, 16 Oct 2021 19:44:02 +0900 Subject: [PATCH] Desktop: Resolves #4827: Laggy scrolling in Markdown viewer (#5496) --- packages/app-desktop/gui/note-viewer/index.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/app-desktop/gui/note-viewer/index.html b/packages/app-desktop/gui/note-viewer/index.html index dda543036bd..d179000bb72 100644 --- a/packages/app-desktop/gui/note-viewer/index.html +++ b/packages/app-desktop/gui/note-viewer/index.html @@ -357,6 +357,17 @@ return m ? contentElement.scrollTop / m : 0; } + contentElement.addEventListener('wheel', webviewLib.logEnabledEventHandler(e => { + // When zoomFactor is not 1 (using an HD display is a typical case), + // DOM element's scrollTop is incorrectly calculated after wheel scroll events + // in the layer of Electron/Chromium, as of 2021-09-23. + // To avoid this problem, prevent the upstream from calculating scrollTop and + // calculate by yourself by accumulating wheel events. + // https://github.com/laurent22/joplin/pull/5496 + contentElement.scrollTop = Math.max(0, Math.min(maxScrollTop(), contentElement.scrollTop + e.deltaY)); + e.preventDefault(); + })); + contentElement.addEventListener('scroll', webviewLib.logEnabledEventHandler(e => { // If the last scroll event was done by the user, lastScrollEventTime is set and // we can use that to skip the event handling. We skip it because in that case