Fix iOS cursor offset
This commit is contained in:
parent
3f73f30f2d
commit
3b807a968c
1 changed files with 8 additions and 0 deletions
|
|
@ -38,6 +38,14 @@ class CanvasHandler {
|
||||||
return unit * Math.sqrt(this.width * this.height);
|
return unit * Math.sqrt(this.width * this.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clientToCanvas(clientX, clientY) {
|
||||||
|
const rect = this.canvas.getBoundingClientRect();
|
||||||
|
return [
|
||||||
|
((clientX - rect.left) / rect.width) * this.width,
|
||||||
|
((clientY - rect.top) / rect.height) * this.height,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
get width() {
|
get width() {
|
||||||
return this.canvas.width / window.devicePixelRatio;
|
return this.canvas.width / window.devicePixelRatio;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue