Skip to content

Commit

Permalink
Desktop: Resolves laurent22#4827: Laggy scrolling in Markdown viewer (l…
Browse files Browse the repository at this point in the history
  • Loading branch information
ken1kob authored and runchard committed Oct 17, 2021
1 parent 18199d2 commit c833aff
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/app-desktop/gui/note-viewer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c833aff

Please sign in to comment.