From 36e49503a6f8aa8d031b5e7e69ab4f328247be3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Wed, 13 May 2026 16:58:41 -0700 Subject: [PATCH] fix(studio): use transform scale instead of CSS zoom for preview stage CSS zoom on absolute inset-2 affects layout metrics, causing the canvas to shift/shrink incorrectly at non-100% zoom levels. transform scale is visual-only (no layout side effects) and aligns with the center-origin pan clamping math in clampPreviewPan. --- packages/studio/src/components/nle/NLEPreview.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/studio/src/components/nle/NLEPreview.tsx b/packages/studio/src/components/nle/NLEPreview.tsx index b60a25f61c..e5349b242e 100644 --- a/packages/studio/src/components/nle/NLEPreview.tsx +++ b/packages/studio/src/components/nle/NLEPreview.tsx @@ -90,8 +90,8 @@ export const NLEPreview = memo(function NLEPreview({ const s = toDomPrecision(state.zoomPercent / 100); const px = toDomPrecision(state.panX); const py = toDomPrecision(state.panY); - stage.style.zoom = String(s); - stage.style.transform = `translate(${px}px, ${py}px)`; + stage.style.zoom = ""; + stage.style.transform = `translate(${px}px, ${py}px) scale(${s})`; }, []); const applyZoom = useCallback( @@ -276,12 +276,11 @@ export const NLEPreview = memo(function NLEPreview({ ref={stageRef} className="absolute inset-2" style={{ - zoom: toDomPrecision(initial.zoomPercent / 100), - transform: `translate(${toDomPrecision(initial.panX)}px, ${toDomPrecision(initial.panY)}px)`, - transformOrigin: "0 0", - outline: "1px solid rgba(255,255,255,0.12)", + transform: `translate(${toDomPrecision(initial.panX)}px, ${toDomPrecision(initial.panY)}px) scale(${toDomPrecision(initial.zoomPercent / 100)})`, + transformOrigin: "50% 50%", + outline: "1px solid rgba(255,255,255,0.3)", outlineOffset: "0px", - boxShadow: "0 4px 32px rgba(0,0,0,0.55)", + boxShadow: "0 4px 32px rgba(0,0,0,0.7)", }} data-testid="preview-zoom-stage" >