Skip to content

Fix video being cropped/zoomed on mobile#118

Merged
modem7 merged 2 commits into
masterfrom
fix/mobile-video-object-fit-zoom
Jul 7, 2026
Merged

Fix video being cropped/zoomed on mobile#118
modem7 merged 2 commits into
masterfrom
fix/mobile-video-object-fit-zoom

Conversation

@modem7

@modem7 modem7 commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

The video is 16:9. With the default object-fit: cover, a narrow/portrait viewport (basically any phone held normally) forces the video to scale up so much to cover the full height that it crops out most of the picture - this is the "zoomed in, doesn't fit" behavior reported on mobile. Desktop was unaffected since wide viewports don't need much cropping to cover in the first place.

Added a max-aspect-ratio: 1/1 media query that switches to object-fit: contain (letterboxed, but the whole frame stays visible) for anything narrower than it is tall, regardless of the OBJECT_FIT env var - cover never looks right in that situation no matter what's configured. Desktop/landscape viewing is completely untouched.

Test plan

  • Verified locally at 375x812 (mobile): full video frame visible, letterboxed, no cropping
  • Verified locally at 1280x800 (desktop): still object-fit: cover, unchanged
  • Added test-mobile-fit.js - Playwright regression test checking computed object-fit at both viewport sizes
  • CI (test.yml) passes

modem7 added 2 commits July 7, 2026 14:36
The video is 16:9. With the default object-fit: cover, a narrow/portrait
viewport (basically any phone held normally) forces the video to scale
up so much to cover the full height that it crops out most of the
picture - reported as "zoomed in" and "doesn't fit". Desktop was
unaffected since wide viewports don't need much cropping to begin with.

Added a max-aspect-ratio: 1/1 media query that switches to object-fit:
contain (letterboxed, but the whole frame stays visible) for anything
narrower than it is tall, regardless of the OBJECT_FIT setting - cover
never looks right in that situation regardless of what's configured.
Verified locally: full frame visible and letterboxed at 375x812, still
cover (untouched) at 1280x800.

Adds a Playwright regression test (test-mobile-fit.js) checking the
computed object-fit at both a narrow/portrait and a wide desktop
viewport size.
Reported as "the error page shows as loading" - not a div-id mixup, the
correct #site-error div was showing the whole time. The <title> tag is
static HTML though, so it always starts as PRE_TITLE ("Loading..." by
default) regardless of which state actually gets picked, and nothing
was overriding it for the error case - so the tab said "Loading..."
over a page that says it errored. Now sets document.title to "Internal
Server Error" when that state is chosen, matching what's on screen.

test-autoplay.js was actually asserting the bug: it hardcoded "Loading..."
as the expected initial title for both overlay types, which passed
before the fix (title genuinely was always "Loading...") and would have
caught this immediately if it had asserted the right value per type.
Fixed to expect the correct title per overlay.

Also broadened test-mobile-fit.js from two viewport checks to six -
mobile/tablet portrait (expect contain), tablet landscape through 4K
desktop (expect cover) - per request to verify all the way up to actual
4K resolution, not just one arbitrary desktop size.
@modem7 modem7 merged commit 88a6e50 into master Jul 7, 2026
3 checks passed
@modem7 modem7 deleted the fix/mobile-video-object-fit-zoom branch July 9, 2026 22:54
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.

1 participant