mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Desktop: Fixes #1867: Fix scrolling issue when clicking on internal link
This commit is contained in:
parent
19f9c4f540
commit
30969f8ab6
@ -161,7 +161,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
let ignoreNextScrollEvent = false;
|
||||
let lastScrollEventTime = 0;
|
||||
ipc.setPercentScroll = (event) => {
|
||||
const percent = event.percent;
|
||||
|
||||
@ -170,7 +170,7 @@
|
||||
checkScrollIID_ = null;
|
||||
}
|
||||
|
||||
ignoreNextScrollEvent = true;
|
||||
lastScrollEventTime = Date.now();
|
||||
setPercentScroll(percent);
|
||||
}
|
||||
|
||||
@ -293,10 +293,20 @@
|
||||
}
|
||||
|
||||
contentElement.addEventListener('scroll', webviewLib.logEnabledEventHandler(e => {
|
||||
if (ignoreNextScrollEvent) {
|
||||
ignoreNextScrollEvent = false;
|
||||
console.info('contentElement.scroll', lastScrollEventTime);
|
||||
|
||||
// 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
|
||||
// the scroll position has already been updated. Also we add a 200ms interval
|
||||
// because otherwise it's most likely a glitch where we called ipc.setPercentScroll
|
||||
// but the scroll event listener has not been called.
|
||||
if (lastScrollEventTime && Date.now() - lastScrollEventTime < 200) {
|
||||
lastScrollEventTime = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
lastScrollEventTime = 0;
|
||||
|
||||
const percent = currentPercentScroll();
|
||||
setPercentScroll(percent);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user