Prevent navigation during horizontal scroll (#6915)

* Prevent unwanted navigation history changes during horizontal scroll on trackpads by evaluating scroll start/end.

Prevent unwanted navigation history changes during horizontal scroll on trackpads by evaluating scroll start/end.

* Fix code reviews and change event listener opts in all implementacion of scroll navegation wheelEvent, scrollHandler

Fix code reviews and change event listener opts in all implementacion of scroll navegation wheelEvent, scrollHandler

* remove line space

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
JA
2025-10-17 22:41:42 +02:00
committed by GitHub
parent d48e2c4cd7
commit 1ed047df3d

View File

@@ -599,6 +599,13 @@ const scrollerFactory = function (frame, options) {
let delta = normalizeWheelDelta(event);
if (transform) {
if (o.horizontal && event.deltaX !== 0
&& (event.deltaY >= -5 && event.deltaY <= 5)
&& (pos.dest + o.scrollBy * delta > 0)
&& (pos.dest + o.scrollBy * delta < pos.end)
) {
event.preventDefault();
}
self.slideBy(o.scrollBy * delta);
} else {
if (isSmoothScrollSupported) {
@@ -630,7 +637,7 @@ const scrollerFactory = function (frame, options) {
});
dom.removeEventListener(scrollSource, wheelEvent, scrollHandler, {
passive: true
passive: false
});
dom.removeEventListener(dragSourceElement, 'touchstart', dragInitSlidee, {
@@ -794,7 +801,7 @@ const scrollerFactory = function (frame, options) {
if (o.mouseWheel) {
// Scrolling navigation
dom.addEventListener(scrollSource, wheelEvent, scrollHandler, {
passive: true
passive: false
});
}
} else if (o.horizontal && o.mouseWheel) {
@@ -802,7 +809,7 @@ const scrollerFactory = function (frame, options) {
// Scrolling navigation
dom.addEventListener(scrollSource, wheelEvent, scrollHandler, {
passive: true
passive: false
});
}