Skip to content

Commit 9119a58

Browse files
committed
Cancel scroll if event was prevented
1 parent 5962157 commit 9119a58

File tree

6 files changed

+16
-7
lines changed

6 files changed

+16
-7
lines changed

dist/smooth-scroll.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* smooth-scroll v16.0.1
2+
* smooth-scroll v16.0.2
33
* Animate scrolling to anchor links
44
* (c) 2019 Chris Ferdinandi
55
* MIT License
@@ -503,6 +503,10 @@
503503
// Don't run if the user prefers reduced motion
504504
if (reduceMotion(settings)) return;
505505

506+
// Don't run if event was canceled but still bubbled up
507+
// By @mgreter - https://github.com/cferdinandi/smooth-scroll/pull/462/
508+
if (event.defaultPrevented) return;
509+
506510
// Don't run if right-click or command/control + click or shift + click
507511
if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey) return;
508512

dist/smooth-scroll.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/smooth-scroll.polyfills.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* smooth-scroll v16.0.1
2+
* smooth-scroll v16.0.2
33
* Animate scrolling to anchor links
44
* (c) 2019 Chris Ferdinandi
55
* MIT License
@@ -573,6 +573,10 @@ if (window.Element && !Element.prototype.closest) {
573573
// Don't run if the user prefers reduced motion
574574
if (reduceMotion(settings)) return;
575575

576+
// Don't run if event was canceled but still bubbled up
577+
// By @mgreter - https://github.com/cferdinandi/smooth-scroll/pull/462/
578+
if (event.defaultPrevented) return;
579+
576580
// Don't run if right-click or command/control + click or shift + click
577581
if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey) return;
578582

0 commit comments

Comments
 (0)