mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Fix #1501 document touchstart/touchmove events are passive by default in chrome and event.preventDefault() calls are ignored
This commit is contained in:
parent
6cbf5292da
commit
cb9fbd7789
1 changed files with 11 additions and 2 deletions
|
@ -23,8 +23,17 @@ 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 eventName = 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 && (eventName === 'touchstart'|| eventName === 'touchmove')
|
||||
? {passive: false}
|
||||
: false;
|
||||
el.addEventListener(eventName, func, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue