Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

Fixed an issue with horizontal scrolling on Windows not moving canvas correctly #230

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/CanvasContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,19 @@ export const CanvasContainer: React.FC = ({ children }) => {
);
}
} else if (!e.metaKey && !e.ctrlKey) {
canvasService.send(canvasModel.events.PAN(e.deltaX, e.deltaY));
const isTrackPad = e.deltaMode === WheelEvent.DOM_DELTA_PIXEL;

if (isTrackPad || !e.shiftKey) {
canvasService.send(canvasModel.events.PAN(e.deltaX, e.deltaY));
} else {
canvasService.send(canvasModel.events.PAN(e.deltaY, 0));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After playing with this a little bit more I'm unsure if this is the best fix for the issue. It works for this specific case but I'm hesitant to say that it's universally good. It would be quite good if I could only apply this for mouse interactions but as far as I can tell they are indistinguishable from touchpad interactions.

}
}
};

const canvasEl = canvasRef.current;
canvasEl.addEventListener('wheel', onCanvasWheel);

return () => {
canvasEl.removeEventListener('wheel', onCanvasWheel);
};
Expand Down