Skip to content

Commit

Permalink
fix: resizing when zoomed
Browse files Browse the repository at this point in the history
  • Loading branch information
UnderKoen committed Oct 2, 2023
1 parent 1cf6035 commit 208737b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/canvas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,12 @@ export default class CanvasModule extends Module<CanvasConfig> {
addLeft = frameRect.left || 0;
}

const zoom = this.getZoomDecimal();
const zoomOffset = 1 / zoom;

return {
y: e.clientY + addTop - yOffset,
x: e.clientX + addLeft - xOffset,
y: (e.clientY + addTop - yOffset) * zoomOffset,
x: (e.clientX + addLeft - xOffset) * zoomOffset,
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/view/Resize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default {
appendTo: canvas.getResizerEl(),
prefix: editor.getConfig().stylePrefix,
posFetcher: canvasView.getElementPos.bind(canvasView),
mousePosFetcher: canvas.getMouseRelativePos,
mousePosFetcher: canvas.getMouseRelativePos.bind(canvas),
...(opt.options || {}),
};
let { canvasResizer } = this;
Expand Down

0 comments on commit 208737b

Please sign in to comment.