mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-09-25 15:49:06 +02:00
touch coordinate fix
This commit is contained in:
@@ -90,13 +90,19 @@ class BaseAPI {
|
||||
*
|
||||
*/
|
||||
getCursorCoords(evt) {
|
||||
const left = evt.target.offsetLeft,
|
||||
top = evt.target.offsetTop;
|
||||
if (evt.targetTouches) {
|
||||
const rect = evt.target.getBoundingClientRect();
|
||||
this.cursor.x = evt.targetTouches[0].pageX - rect.left;
|
||||
this.cursor.y = evt.targetTouches[0].pageY - rect.top;
|
||||
const touch = evt.targetTouches;
|
||||
for (let i=0; i<touch.length; i++) {
|
||||
if (!touch[i] || !touch[i].pageX) continue;
|
||||
this.cursor.x = touch[i].pageX - left;
|
||||
this.cursor.y = touch[i].pageY - top;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
this.cursor.x = evt.offsetX;
|
||||
this.cursor.y = evt.offsetY;
|
||||
this.cursor.x = evt.pageX - left;
|
||||
this.cursor.y = evt.pageY - top;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user