mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-09-03 21:32:44 +02:00
touch handling
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
class BaseAPI {
|
class BaseAPI {
|
||||||
static get privateMethods() {
|
static get privateMethods() {
|
||||||
return [`constructor`, `addListeners`, `getMouseCoords`]
|
return [`constructor`, `addListeners`, `getCursorCoords`]
|
||||||
.concat(this.superCallers)
|
.concat(this.superCallers)
|
||||||
.concat(this.eventHandlers);
|
.concat(this.eventHandlers);
|
||||||
}
|
}
|
||||||
@@ -89,10 +89,16 @@ class BaseAPI {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
getMouseCoords(evt) {
|
getCursorCoords(evt) {
|
||||||
|
if (e.targetTouches) {
|
||||||
|
const rect = e.target.getBoundingClientRect();
|
||||||
|
this.cursor.x = e.targetTouches[0].pageX - rect.left;
|
||||||
|
this.cursor.y = e.targetTouches[0].pageY - rect.top;
|
||||||
|
} else {
|
||||||
this.cursor.x = evt.offsetX;
|
this.cursor.x = evt.offsetX;
|
||||||
this.cursor.y = evt.offsetY;
|
this.cursor.y = evt.offsetY;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -101,7 +107,7 @@ class BaseAPI {
|
|||||||
stop(evt);
|
stop(evt);
|
||||||
this.cursor.button = evt.button;
|
this.cursor.button = evt.button;
|
||||||
this.cursor.down = true;
|
this.cursor.down = true;
|
||||||
this.getMouseCoords(evt);
|
this.getCursorCoords(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,7 +117,7 @@ class BaseAPI {
|
|||||||
stop(evt);
|
stop(evt);
|
||||||
this.cursor.button = undefined;
|
this.cursor.button = undefined;
|
||||||
this.cursor.move = true;
|
this.cursor.move = true;
|
||||||
this.getMouseCoords(evt);
|
this.getCursorCoords(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,7 +128,7 @@ class BaseAPI {
|
|||||||
this.cursor.button = evt.button;
|
this.cursor.button = evt.button;
|
||||||
this.cursor.down = false;
|
this.cursor.down = false;
|
||||||
this.cursor.move = false;
|
this.cursor.move = false;
|
||||||
this.getMouseCoords(evt);
|
this.getCursorCoords(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user