Skip to content

@remotion/studio: Add padding when fitting compositions - #9339

Merged
JonnyBurger merged 2 commits into
mainfrom
codex/studio-fit-padding
Jul 20, 2026
Merged

@remotion/studio: Add padding when fitting compositions#9339
JonnyBurger merged 2 commits into
mainfrom
codex/studio-fit-padding

Conversation

@JonnyBurger

Copy link
Copy Markdown
Member

Summary

  • leave a 16px screen-space gutter around compositions when Studio preview size is set to Fit
  • keep assets and explicit zoom levels unchanged
  • use the padded Fit scale consistently for zoom gestures, drops, rulers, guides, and useCurrentScale()

Testing

  • bun test packages/studio/src/test/studio-fit-padding.test.ts
  • bun run build
  • bun run stylecheck

Closes #9337

@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bugs Ready Ready Preview, Comment Jul 20, 2026 12:33pm
remotion Ready Ready Preview, Comment Jul 20, 2026 12:33pm

Request Review

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — This PR adds a 16px screen-space gutter around compositions when Remotion Studio's preview size is set to Fit, while leaving asset previews and explicit zoom levels unchanged.

  • Adds packages/studio/src/helpers/studio-fit-padding.ts — New utilities (calculateStudioScale, calculateStudioCanvasTransformation, getStudioPaddedCanvasSize) compute the padded canvas size and apply the padding as a translation for auto-fit positioning.
  • Threads addFitPadding through Canvas.tsx and get-effective-translation.ts — All scale computations for compositions now use the padded canvas size, including zoom gestures, drop positioning, and zoom-in/zoom-out actions.
  • Updates Preview.tsx and use-studio-canvas-dimensions.ts — Rendering and overlay dimensions use the padded transformation, while non-composition content keeps the original PlayerInternals behavior.
  • Provides padded canvas size via Editor.tsx CurrentScaleContextuseCurrentScale() now reports the same padded fit scale as the visual preview.
  • Adds unit testsstudio-fit-padding.test.ts covers width-constrained, height-constrained, and explicit-zoom cases.

Pullfrog  | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues in the new commit.

Reviewed changes since last review — The follow-up commit "@remotion/studio: Fix asymmetric Fit padding" separates the full layout canvas size from the padded canvas size used only for auto-fit scale calculations in useCurrentScale().

  • Adds InternalCurrentScaleContextType in packages/core/src/use-current-scale.ts — Extends the internal 'canvas-size' context with canvasSizeForAuto so the layout bounds remain the actual container size while auto-fit scale uses the padded bounds.
  • Updates useCurrentScale() to read canvasSizeForAuto — Auto-fit now respects the 16px Studio gutter; explicit zoom levels still ignore canvas size and return the numeric zoom.
  • Adds getStudioCurrentScaleContext() in packages/studio/src/helpers/studio-fit-padding.ts — Studio's CurrentScaleContext.Provider now supplies both sizes without leaking the padding into layout math.
  • Updates Editor.tsx — Replaces the unconditional padded canvasSize value with getStudioCurrentScaleContext(size).
  • Adds a test for size separationkeeps the layout size separate from the auto-fit size verifies that canvasSize stays at the full container size while canvasSizeForAuto reflects the padding.

Pullfrog  | Fix it ➔View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@JonnyBurger
JonnyBurger merged commit 4a1a5d6 into main Jul 20, 2026
20 checks passed
@JonnyBurger
JonnyBurger deleted the codex/studio-fit-padding branch July 20, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should "Fit" in Studio leave a bit of padding so the interactivity outline can be seen?

1 participant