mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: Visibility and zooming when canvas offset is not zero (#2534)
This commit is contained in:
parent
60864ace54
commit
4c7b1a2269
5 changed files with 53 additions and 19 deletions
|
@ -3,6 +3,7 @@ import { NormalizedZoomValue, PointerCoords, Zoom } from "../types";
|
|||
export const getNewZoom = (
|
||||
newZoomValue: NormalizedZoomValue,
|
||||
prevZoom: Zoom,
|
||||
canvasOffset: { left: number; top: number },
|
||||
zoomOnViewportPoint: PointerCoords = { x: 0, y: 0 },
|
||||
): Zoom => {
|
||||
return {
|
||||
|
@ -10,11 +11,13 @@ export const getNewZoom = (
|
|||
translation: {
|
||||
x:
|
||||
zoomOnViewportPoint.x -
|
||||
(zoomOnViewportPoint.x - prevZoom.translation.x) *
|
||||
canvasOffset.left -
|
||||
(zoomOnViewportPoint.x - canvasOffset.left - prevZoom.translation.x) *
|
||||
(newZoomValue / prevZoom.value),
|
||||
y:
|
||||
zoomOnViewportPoint.y -
|
||||
(zoomOnViewportPoint.y - prevZoom.translation.y) *
|
||||
canvasOffset.top -
|
||||
(zoomOnViewportPoint.y - canvasOffset.top - prevZoom.translation.y) *
|
||||
(newZoomValue / prevZoom.value),
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue