From c1df87582d08202f53217b5de92b1bfc510446c6 Mon Sep 17 00:00:00 2001 From: caribaud Date: Fri, 26 May 2023 23:32:11 +0200 Subject: [PATCH] Change scrolling behaviour --- melpomene.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/melpomene.js b/melpomene.js index 04ac503..1ca0744 100644 --- a/melpomene.js +++ b/melpomene.js @@ -459,7 +459,19 @@ function handleKeyPress(key){ } -function handleMouseWhell(deltaY){ +function handleMouseWhell(event){ + + // Only handle scroll event if the target is the nav controls + // to avoid preventing page scrolling. + + // Do disable page scrolling when we do prev/next, though + + if (! READER_FRAME.contains(event.target)){ + return + } + + event.preventDefault() + event.stopPropagation() if (MOUSEWHELL_WAIT){ return @@ -470,7 +482,7 @@ function handleMouseWhell(deltaY){ }, MOUSEWHELL_MIN_DELAY) } - if (deltaY > 0) { + if (event.deltaY > 0) { moveReader(true, false) } @@ -497,5 +509,5 @@ addEventListener("keydown", (event) => { }); addEventListener("wheel", (event) => { - handleMouseWhell(event.deltaY) -}); + handleMouseWhell(event) +}, { passive:false });