Skip to content

Commit 6aaf3ed

Browse files
committed
fix(studio): use CSS transform scale instead of zoom for preview stage
CSS zoom is a layout property — changing it triggers ResizeObserver on descendant elements, which causes scaleIframeToFit to re-run with getBoundingClientRect values already inflated by the zoom factor. The iframe ends up scaled too small, leaving visible letterbox as zoom increases (the reported "canvas border expands inward" bug). CSS transform scale is visual-only. ResizeObserver never fires on scale changes, so scaleIframeToFit keeps the scale it computed on initial mount (based on layout dimensions). The parent transform then magnifies the player and composition uniformly, so the composition always fills the player's visual bounds. Also switches transformOrigin from "0 0" to "50% 50%" so zooming is centred, which matches the clampPreviewPan formula that already assumes a centre origin for pan clamping. Closes #752
1 parent 1caeb28 commit 6aaf3ed

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

‎packages/studio/src/components/nle/NLEPreview.tsx‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ export const NLEPreview = memo(function NLEPreview({
9090
const s = toDomPrecision(state.zoomPercent / 100);
9191
const px = toDomPrecision(state.panX);
9292
const py = toDomPrecision(state.panY);
93-
stage.style.zoom = String(s);
94-
stage.style.transform = `translate(${px}px, ${py}px)`;
93+
stage.style.transform = `translate(${px}px, ${py}px) scale(${s})`;
9594
}, []);
9695

9796
const applyZoom = useCallback(
@@ -276,9 +275,8 @@ export const NLEPreview = memo(function NLEPreview({
276275
ref={stageRef}
277276
className="absolute inset-2"
278277
style={{
279-
zoom: toDomPrecision(initial.zoomPercent / 100),
280-
transform: `translate(${toDomPrecision(initial.panX)}px, ${toDomPrecision(initial.panY)}px)`,
281-
transformOrigin: "0 0",
278+
transform: `translate(${toDomPrecision(initial.panX)}px, ${toDomPrecision(initial.panY)}px) scale(${toDomPrecision(initial.zoomPercent / 100)})`,
279+
transformOrigin: "50% 50%",
282280
}}
283281
data-testid="preview-zoom-stage"
284282
>

0 commit comments

Comments
 (0)