Skip to content

Commit fdd2359

Browse files
committed
fixes #1019 for all mobile browser which support event listener options
[https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener]
1 parent 6c2f289 commit fdd2359

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

src/events.js

Lines changed: 3 additions & 12 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-
if (!navigator.userAgent.match(/chrome|chromium|crios/i)) {
82-
event.originalEvent.preventDefault();
83-
}
8481
if (!ctx.options.touchEnabled) {
8582
return;
8683
}
@@ -95,9 +92,6 @@ export default function(ctx) {
9592
};
9693

9794
events.touchmove = function(event) {
98-
if (!navigator.userAgent.match(/chrome|chromium|crios/i)) {
99-
event.originalEvent.preventDefault();
100-
}
10195
if (!ctx.options.touchEnabled) {
10296
return;
10397
}
@@ -107,9 +101,6 @@ export default function(ctx) {
107101
};
108102

109103
events.touchend = function(event) {
110-
if (!navigator.userAgent.match(/chrome|chromium|crios/i)) {
111-
event.originalEvent.preventDefault();
112-
}
113104
if (!ctx.options.touchEnabled) {
114105
return;
115106
}
@@ -228,9 +219,9 @@ export default function(ctx) {
228219
ctx.map.on('mouseup', events.mouseup);
229220
ctx.map.on('data', events.data);
230221

231-
ctx.map.on('touchmove', events.touchmove);
232-
ctx.map.on('touchstart', events.touchstart);
233-
ctx.map.on('touchend', events.touchend);
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});
234225

235226
ctx.container.addEventListener('mouseout', events.mouseout);
236227

0 commit comments

Comments
 (0)