Repository navigation
fix(mobile): file preview videos keep their own aspect ratio #21894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
maria-rcks
merged 9 commits into
pingdotgg:main
from
NikitaMGrimm:fix/mobile-file-preview-video-aspect
Oct 30, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5881b8a
fix(mobile): file preview videos keep their own aspect ratio
NikitaMGrimm d1bfc62
fix(mobile): tapping Play no longer restarts the Files preview size p…
NikitaMGrimm fd8b545
Merge remote-tracking branch 'origin/main' into pr21894
NikitaMGrimm 8c83f9b
fix(mobile): merge main into file video preview fix
maria-rcks 1882dc1
fix(mobile): explain native frame dimension synchronization
maria-rcks 39e16d4
fix(mobile): preserve video visibility handling from main
maria-rcks d475b7c
fix(mobile): merge main into file video preview fix
maria-rcks 4e088b0
fix(mobile): merge main while preserving video frame sizing
maria-rcks 2321ea0
fix(mobile): cancel file video sizing when leaving the screen
maria-rcks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { describe, expect, it } from "vite-plus/test"; | ||
|
|
||
| import { fitVideoFrame } from "./videoFrameFit"; | ||
|
|
||
| describe("fitVideoFrame", () => { | ||
| const bounds = { width: 360, height: 600 }; | ||
|
|
||
| it("keeps landscape videos at the full capped width", () => { | ||
| expect(fitVideoFrame({ width: 1920, height: 1080 }, bounds, 480)).toEqual({ | ||
| width: 360, | ||
| height: 202.5, | ||
| }); | ||
| }); | ||
|
|
||
| it("limits portrait videos by the available height", () => { | ||
| expect(fitVideoFrame({ width: 1080, height: 1920 }, bounds, 480)).toEqual({ | ||
| width: 337.5, | ||
| height: 600, | ||
| }); | ||
| }); | ||
|
|
||
| it("caps wide bounds at the inline width", () => { | ||
| expect(fitVideoFrame({ width: 1080, height: 1080 }, { width: 800, height: 900 }, 480)).toEqual({ | ||
| width: 480, | ||
| height: 480, | ||
| }); | ||
| }); | ||
|
|
||
| it("returns null before the video or bounds have a size", () => { | ||
| expect(fitVideoFrame({ width: 0, height: 0 }, bounds, 480)).toBeNull(); | ||
| expect(fitVideoFrame({ width: 1080, height: 1920 }, { width: 0, height: 0 }, 480)).toBeNull(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| interface Size { | ||
| readonly width: number; | ||
| readonly height: number; | ||
| } | ||
|
|
||
| /** Largest frame with the video's aspect ratio that fits the bounds and the inline width cap. */ | ||
| export function fitVideoFrame(video: Size, bounds: Size, maxWidth: number): Size | null { | ||
| if (video.width <= 0 || video.height <= 0 || bounds.width <= 0 || bounds.height <= 0) { | ||
| return null; | ||
| } | ||
| const ratio = video.width / video.height; | ||
| const width = Math.min(bounds.width, maxWidth, bounds.height * ratio); | ||
| return { width, height: width / ratio }; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.