mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Refactor code to fit style rules
This commit is contained in:
parent
54e1a0c1ef
commit
c034ebf554
2 changed files with 19 additions and 13 deletions
|
@ -24,15 +24,17 @@ var DomEvent = /** @lends DomEvent */{
|
||||||
var func = events[type],
|
var func = events[type],
|
||||||
parts = type.split(/[\s,]+/g);
|
parts = type.split(/[\s,]+/g);
|
||||||
for (var i = 0, l = parts.length; i < l; i++) {
|
for (var i = 0, l = parts.length; i < l; i++) {
|
||||||
var eventName = parts[i];
|
var name = parts[i];
|
||||||
// For touchstart/touchmove events on document, we need to explicitely
|
// For touchstart/touchmove events on document, we need to
|
||||||
// declare that event is not passive (can be prevented).
|
// explicitely declare that event is not passive (can be
|
||||||
// Otherwise chrome browser would ignore event.preventDefault() calls.
|
// prevented). Otherwise chrome browser would ignore
|
||||||
// See #1501 and https://www.chromestatus.com/features/5093566007214080
|
// event.preventDefault() calls. See #1501 and
|
||||||
var options = el === document && (eventName === 'touchstart'|| eventName === 'touchmove')
|
// https://www.chromestatus.com/features/5093566007214080
|
||||||
? {passive: false}
|
var options = (
|
||||||
: false;
|
el === document
|
||||||
el.addEventListener(eventName, func, options);
|
&& (name === 'touchstart' || name === 'touchmove')
|
||||||
|
) ? { passive: false } : false;
|
||||||
|
el.addEventListener(name, func, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1441,11 +1441,15 @@ new function() { // Injection scope for event handling on the browser
|
||||||
// - If this is a unhandled mousedown event, but the view or tools
|
// - If this is a unhandled mousedown event, but the view or tools
|
||||||
// respond to mouseup.
|
// respond to mouseup.
|
||||||
//
|
//
|
||||||
// Some events are not cancelable anyway (like during a scroll inertia
|
// Some events are not cancelable anyway (like during a scroll
|
||||||
// on mobile) so trying to prevent default in those case would result
|
// inertia on mobile) so trying to prevent default in those case
|
||||||
// in no effect and an error.
|
// would result in no effect and an error.
|
||||||
if (event.cancelable !== false && (called && !mouse.move || mouse.down && responds('mouseup')))
|
if (
|
||||||
|
event.cancelable !== false
|
||||||
|
&& (called && !mouse.move || mouse.down && responds('mouseup'))
|
||||||
|
) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue