Skip to content

Commit 5a90472

Browse files
authored
Revert "Use passive event listeners instead of preventDefault (#1146) (h/t @danielsippel)" (#1158)
This reverts commit 84e35b7.
1 parent e300ebd commit 5a90472

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/events.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ 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();
8184
if (!ctx.options.touchEnabled) {
8285
return;
8386
}
@@ -92,6 +95,7 @@ export default function(ctx) {
9295
};
9396

9497
events.touchmove = function(event) {
98+
event.originalEvent.preventDefault();
9599
if (!ctx.options.touchEnabled) {
96100
return;
97101
}
@@ -101,6 +105,7 @@ export default function(ctx) {
101105
};
102106

103107
events.touchend = function(event) {
108+
event.originalEvent.preventDefault();
104109
if (!ctx.options.touchEnabled) {
105110
return;
106111
}
@@ -219,9 +224,9 @@ export default function(ctx) {
219224
ctx.map.on('mouseup', events.mouseup);
220225
ctx.map.on('data', events.data);
221226

222-
ctx.map.on('touchmove', events.touchmove, {passive:true});
223-
ctx.map.on('touchstart', events.touchstart, {passive:true});
224-
ctx.map.on('touchend', events.touchend, {passive:true});
227+
ctx.map.on('touchmove', events.touchmove);
228+
ctx.map.on('touchstart', events.touchstart);
229+
ctx.map.on('touchend', events.touchend);
225230

226231
ctx.container.addEventListener('mouseout', events.mouseout);
227232

0 commit comments

Comments
 (0)