Skip to content

Commit 354e296

Browse files
authored
Remove preventDefault() on touchstart and touchmove events (#1195)
* Remove preventDefault() on touchstart and touchmove events Touchstart and touchmove listeners added to the document by default as passive, so that calls to preventDefault will be ignored and will create a browser error like "Unable to preventDefault inside passive event". This resolves issues #1019, #1054 * Revert comment before preventDefault and put it inside touchend
1 parent 357ede0 commit 354e296

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/events.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ export default function(ctx) {
7878
};
7979

8080
events.touchstart = function(event) {
81-
// Prevent emulated mouse events because we will fully handle the touch here.
82-
// This does not stop the touch events from propogating to mapbox though.
83-
event.originalEvent.preventDefault();
8481
if (!ctx.options.touchEnabled) {
8582
return;
8683
}
@@ -95,7 +92,6 @@ export default function(ctx) {
9592
};
9693

9794
events.touchmove = function(event) {
98-
event.originalEvent.preventDefault();
9995
if (!ctx.options.touchEnabled) {
10096
return;
10197
}
@@ -105,6 +101,8 @@ export default function(ctx) {
105101
};
106102

107103
events.touchend = function(event) {
104+
// Prevent emulated mouse events because we will fully handle the touch here.
105+
// This does not stop the touch events from propogating to mapbox though.
108106
event.originalEvent.preventDefault();
109107
if (!ctx.options.touchEnabled) {
110108
return;

0 commit comments

Comments
 (0)