From 77471be39d0e1da776c339bc502938ace066381f Mon Sep 17 00:00:00 2001 From: Tibi Neagu Date: Tue, 12 Jul 2022 17:29:54 +0100 Subject: [PATCH] Corrected shouldBeConsumedByChild logic for vertical scrolling; fixes mdbootstrap/perfect-scrollbar#139 --- src/handlers/mouse-wheel.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/handlers/mouse-wheel.js b/src/handlers/mouse-wheel.js index 840e269..29fe5cf 100644 --- a/src/handlers/mouse-wheel.js +++ b/src/handlers/mouse-wheel.js @@ -81,9 +81,12 @@ export default function(i) { if (deltaY && style.overflowY.match(/(scroll|auto)/)) { const maxScrollTop = cursor.scrollHeight - cursor.clientHeight; if (maxScrollTop > 0) { + // Note: negative deltaY means scrolling down if ( - (cursor.scrollTop > 0 && deltaY < 0) || - (cursor.scrollTop < maxScrollTop && deltaY > 0) + // Already scrolled vertically, user is scrolling up + (cursor.scrollTop > 0 && deltaY > 0) || + // Hasn't reached bottom, user is scrolling down + (cursor.scrollTop < maxScrollTop && deltaY < 0) ) { return true; }