Skip to content

Commit 559e3e4

Browse files
committed
Prevent scrolling if event was canceled by inner handler
Since smooth-scroll event is attached to the body, another handler may cancel the default behavior, but the event will still bubble up to the body, triggering a page scroll. It seems reasonable that if any inner event handle cancels the default behavior that no scrolling should be triggered.
1 parent 61d1e74 commit 559e3e4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/js/smooth-scroll/smooth-scroll.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,9 @@
495495
// Don't run if the user prefers reduced motion
496496
if (reduceMotion(settings)) return;
497497

498+
// Don't run if event was canceled but still bubbled up
499+
if (event.defaultPrevented) return;
500+
498501
// Don't run if right-click or command/control + click
499502
if (event.button !== 0 || event.metaKey || event.ctrlKey) return;
500503

0 commit comments

Comments
 (0)