@pixerate/editor-svelte 0.127.0 → 0.127.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -208,7 +208,9 @@
|
|
|
208
208
|
let isPanning = $state(false);
|
|
209
209
|
// A primary drag pans: Space held, or the host's pan mode.
|
|
210
210
|
const panning = $derived(viewportGestures && (isSpacePressed || panMode));
|
|
211
|
-
|
|
211
|
+
// Where a pan drag started, in view pixels: a scaled host (an expanded studio in a zoomed-out
|
|
212
|
+
// canvas) makes screen pixels larger or smaller than the pan's.
|
|
213
|
+
let panStartPoint: ImagePoint | null = null;
|
|
212
214
|
let panStartOffset: { x: number; y: number } = { x: 0, y: 0 };
|
|
213
215
|
|
|
214
216
|
function handleWheel(e: WheelEvent) {
|
|
@@ -629,7 +631,7 @@
|
|
|
629
631
|
if (viewportGestures && (e.button === 1 || (e.button === 0 && panning))) {
|
|
630
632
|
e.preventDefault();
|
|
631
633
|
isPanning = true;
|
|
632
|
-
panStartPoint =
|
|
634
|
+
panStartPoint = getCanvasEventPoint(e);
|
|
633
635
|
const curPan = editor.controller.getState().pan || { x: 0, y: 0 };
|
|
634
636
|
panStartOffset = { ...curPan };
|
|
635
637
|
return;
|
|
@@ -732,8 +734,9 @@
|
|
|
732
734
|
if (!canvasEl) return;
|
|
733
735
|
|
|
734
736
|
if (isPanning && panStartPoint) {
|
|
735
|
-
const
|
|
736
|
-
const
|
|
737
|
+
const pt = getCanvasEventPoint(e);
|
|
738
|
+
const dx = pt.x - panStartPoint.x;
|
|
739
|
+
const dy = pt.y - panStartPoint.y;
|
|
737
740
|
editor.controller.setPan({
|
|
738
741
|
x: Math.round(panStartOffset.x + dx),
|
|
739
742
|
y: Math.round(panStartOffset.y + dy),
|