Skip to content

Commit

Permalink
fix: 🐛 Workaround for horizontal scrolling
Browse files Browse the repository at this point in the history
Partly fixes #47. We now also disable scrolling on the `wheel` event if we hover over a canvas element, canvas node or image.

This way we still scroll a little bit before the wheel event disables the scrolling but at least we stop scrolling indefinetly.
  • Loading branch information
nicojeske committed Mar 22, 2024
1 parent 49c7366 commit 7d949da
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions main.ts
Expand Up @@ -85,16 +85,24 @@ export default class MouseWheelZoomPlugin extends Plugin {
}

const eventTarget = evt.target as Element;
if (eventTarget.hasClass("canvas-node-content-blocker")){

const targetIsCanvas: boolean = eventTarget.hasClass("canvas-node-content-blocker")
const targetIsCanvasNode: boolean = eventTarget.closest(".canvas-node-content") !== null;
const targetIsImage: boolean = eventTarget.nodeName === "IMG";

if (targetIsCanvas || targetIsCanvasNode || targetIsImage) {
this.disableScroll(currentWindow);
}

if (targetIsCanvas){
// seems we're trying to zoom on some canvas node.
this.handleZoomForCanvas(evt, eventTarget);

}
else if (eventTarget.closest(".canvas-node-content")) {
else if (targetIsCanvasNode) {
// we trying to resize focused canvas node.
// i think here can be implementation of zoom images in embded markdown files on canvas.
}
else if (eventTarget.nodeName === "IMG") {
else if (targetIsImage) {
// Handle the zooming of the image
this.handleZoom(evt, eventTarget);
}
Expand Down

0 comments on commit 7d949da

Please sign in to comment.