Skip to content

Commit aab083a

Browse files
committed
Fix mouse event coordinates
Signed-off-by: martinRenou <[email protected]>
1 parent 51e719e commit aab083a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/widget.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,9 @@ class CanvasView extends DOMWidgetView {
400400

401401
protected getCoordinates(event: MouseEvent | Touch) {
402402
const rect = this.el.getBoundingClientRect();
403-
const x = event.clientX - rect.left;
404-
const y = event.clientY - rect.top;
403+
404+
const x = this.el.width * (event.clientX - rect.left) / rect.width;
405+
const y = this.el.height * (event.clientY - rect.top) / rect.height;
405406

406407
return { x, y };
407408
}

0 commit comments

Comments
 (0)