mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Merge pull request #1533 from sasensi/Fix_#1501_errors_with_event_listeners_on_mobile
Fix #1501 errors with event listeners on mobile
This commit is contained in:
commit
9201ea973e
2 changed files with 22 additions and 3 deletions
|
@ -23,8 +23,19 @@ var DomEvent = /** @lends DomEvent */{
|
|||
for (var type in events) {
|
||||
var func = events[type],
|
||||
parts = type.split(/[\s,]+/g);
|
||||
for (var i = 0, l = parts.length; i < l; i++)
|
||||
el.addEventListener(parts[i], func, false);
|
||||
for (var i = 0, l = parts.length; i < l; i++) {
|
||||
var name = parts[i];
|
||||
// For touchstart/touchmove events on document, we need to
|
||||
// explicitely declare that event is not passive (can be
|
||||
// prevented). Otherwise chrome browser would ignore
|
||||
// event.preventDefault() calls. See #1501 and
|
||||
// https://www.chromestatus.com/features/5093566007214080
|
||||
var options = (
|
||||
el === document
|
||||
&& (name === 'touchstart' || name === 'touchmove')
|
||||
) ? { passive: false } : false;
|
||||
el.addEventListener(name, func, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1440,8 +1440,16 @@ new function() { // Injection scope for event handling on the browser
|
|||
// which can call `preventDefault()` explicitly or return `false`.
|
||||
// - If this is a unhandled mousedown event, but the view or tools
|
||||
// respond to mouseup.
|
||||
if (called && !mouse.move || mouse.down && responds('mouseup'))
|
||||
//
|
||||
// Some events are not cancelable anyway (like during a scroll
|
||||
// inertia on mobile) so trying to prevent default in those case
|
||||
// would result in no effect and an error.
|
||||
if (
|
||||
event.cancelable !== false
|
||||
&& (called && !mouse.move || mouse.down && responds('mouseup'))
|
||||
) {
|
||||
event.preventDefault();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue