chore: prettier packages codes

This commit is contained in:
陈嘉涵
2020-01-19 14:09:32 +08:00
parent 389d68884d
commit 1575bea6f5
18 changed files with 113 additions and 80 deletions

View File

@@ -9,16 +9,30 @@ var supportTouch = 'ontouchstart' in window;
// polyfills
if (!document.createTouch) {
document.createTouch = function(view, target, identifier, pageX, pageY, screenX, screenY) {
document.createTouch = function(
view,
target,
identifier,
pageX,
pageY,
screenX,
screenY
) {
// auto set
return new Touch(target, identifier, {
pageX: pageX,
pageY: pageY,
screenX: screenX,
screenY: screenY,
clientX: pageX - window.pageXOffset,
clientY: pageY - window.pageYOffset
}, 0, 0);
return new Touch(
target,
identifier,
{
pageX: pageX,
pageY: pageY,
screenX: screenX,
screenY: screenY,
clientX: pageX - window.pageXOffset,
clientY: pageY - window.pageYOffset,
},
0,
0
);
};
}
@@ -78,15 +92,12 @@ function TouchList() {
return touchList;
}
/**
* only trigger touches when the left mousebutton has been pressed
* @param touchType
* @returns {Function}
*/
var initiated = false;
function onMouse(touchType) {
return function(ev) {
@@ -101,13 +112,17 @@ function onMouse(touchType) {
}
if (ev.type === 'mousemove' && !initiated) {
return
return;
}
// The EventTarget on which the touch point started when it was first placed on the surface,
// even if the touch point has since moved outside the interactive area of that element.
// also, when the target doesnt exist anymore, we update it
if (ev.type === 'mousedown' || !eventTarget || eventTarget && !eventTarget.dispatchEvent) {
if (
ev.type === 'mousedown' ||
!eventTarget ||
(eventTarget && !eventTarget.dispatchEvent)
) {
eventTarget = ev.target;
}