make zooming zoom toward the mouse cursor
This commit is contained in:
parent
385a691e3e
commit
2a783aba71
2 changed files with 22 additions and 2 deletions
|
@ -433,12 +433,15 @@ class CanvasRenderer extends HTMLElement {
|
|||
}
|
||||
}
|
||||
|
||||
async #zoomingBehaviour() {
|
||||
#zoomingBehaviour() {
|
||||
this.addEventListener(
|
||||
"wheel",
|
||||
(event) => {
|
||||
// TODO: Touchpad zoom
|
||||
this.viewport.zoomIn(event.deltaY > 0 ? -1 : 1);
|
||||
let windowSize = this.getWindowSize();
|
||||
let ndcX = (event.clientX - this.clientLeft) / windowSize.width - 0.5;
|
||||
let ndcY = (event.clientY - this.clientTop) / windowSize.height - 0.5;
|
||||
this.viewport.zoomIntoPoint(event.deltaY > 0 ? -1 : 1, ndcX, ndcY, windowSize);
|
||||
this.sendViewportUpdate();
|
||||
this.dispatchEvent(new Event(".viewportUpdateEnd"));
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue