fix(screen-share): correct fullscreen dimensions

This commit is contained in:
illusia committed 2026-10-18 11:10:54 +08:00
1 parent 180bfeb52f
commit 32d84435ce
3 files changed
+43 -4

No files matched your search

@@ -138,18 +138,35 @@ function updateStageSize(): void {
const stage = stageElement.value;
const player = playerElement.value ?? stage?.parentElement ?? null;
if (!stage || !player) return;
if (screenShareFullscreen.value) {
// Read the browser's fullscreen element directly. The Vue state is updated
// by a separate fullscreenchange listener and can lag the layout transition.
if (typeof document !== "undefined" && document.fullscreenElement === player) {
const fullscreenHeight = typeof CSS !== "undefined" && CSS.supports("height", "100dvh") ? "100dvh" : "100vh";
setInlineStyle(player, "position", "fixed");
setInlineStyle(player, "inset", "0");
setInlineStyle(player, "width", "100vw");
setInlineStyle(player, "height", "100vh");
setInlineStyle(player, "height", fullscreenHeight);
setInlineStyle(player, "max-width", "none");
setInlineStyle(player, "max-height", "none");
setInlineStyle(player, "margin", "0");
setInlineStyle(stage, "width", "100%");
setInlineStyle(stage, "height", "100%");
setInlineStyle(stage, "min-height", "0");
setInlineStyle(stage, "max-height", "none");
setInlineStyle(stage, "aspect-ratio", "auto");
return;
}
setInlineStyle(player, "position", null);
setInlineStyle(player, "inset", null);
setInlineStyle(player, "width", null);
setInlineStyle(player, "height", null);
setInlineStyle(player, "max-width", null);
setInlineStyle(player, "max-height", null);
setInlineStyle(player, "margin", null);
setInlineStyle(stage, "width", null);
setInlineStyle(stage, "height", null);
setInlineStyle(stage, "min-height", null);
setInlineStyle(stage, "max-height", null);
setInlineStyle(stage, "aspect-ratio", "auto");
}
@@ -168,9 +185,13 @@ function setStageElement(element: unknown): void {
updateStageSize();
}
onMounted(() => window.addEventListener("resize", updateStageSize));
onMounted(() => {
window.addEventListener("resize", updateStageSize);
document.addEventListener("fullscreenchange", updateStageSize);
});
watch(screenShareFullscreen, updateStageSize);
onBeforeUnmount(() => {
window.removeEventListener("resize", updateStageSize);
document.removeEventListener("fullscreenchange", updateStageSize);
});
</script>
+9 -1
View File
@@ -7388,15 +7388,23 @@
}
:deep(.screen-share-player:fullscreen) {
position: fixed;
inset: 0;
width: 100vw;
height: 100vh;
height: 100dvh;
max-width: none;
max-height: none;
margin: 0;
border: 0;
border-radius: 0;
background: var(--surface-0);
background: #000;
}
:deep(.screen-share-player:fullscreen .screen-share-player-stage) {
width: 100%;
height: 100%;
min-height: 0;
max-height: none;
aspect-ratio: auto;
}
+10
View File
@@ -48,6 +48,8 @@ test("screen-share player fills the content width, limits height, and letterboxe
const playerRule = css.match(/:deep\(\.screen-share-player\)\s*\{([^}]*)\}/)?.[1] ?? "";
const stageRule = css.match(/:deep\(\.screen-share-player-stage\)\s*\{([^}]*)\}/)?.[1] ?? "";
const videoRule = css.match(/:deep\(\.screen-share-player-video\)\s*\{([^}]*)\}/)?.[1] ?? "";
const fullscreenRule = css.match(/:deep\(\.screen-share-player:fullscreen\)\s*\{([^}]*)\}/)?.[1] ?? "";
const fullscreenStageRule = css.match(/:deep\(\.screen-share-player:fullscreen \.screen-share-player-stage\)\s*\{([^}]*)\}/)?.[1] ?? "";
assert.match(playerRule, /width:\s*100%/);
assert.doesNotMatch(playerRule, /width:\s*fit-content/);
assert.match(stageRule, /width:\s*100%/);
@@ -55,6 +57,14 @@ test("screen-share player fills the content width, limits height, and letterboxe
assert.match(stageRule, /background:\s*#000/);
assert.match(videoRule, /object-fit:\s*contain/);
assert.match(videoRule, /background:\s*#000/);
assert.match(fullscreenRule, /position:\s*fixed/);
assert.match(fullscreenRule, /inset:\s*0/);
assert.match(fullscreenRule, /height:\s*100dvh/);
assert.match(fullscreenRule, /background:\s*#000/);
assert.match(fullscreenStageRule, /height:\s*100%/);
assert.match(fullscreenStageRule, /min-height:\s*0/);
assert.match(component, /document\.addEventListener\("fullscreenchange", updateStageSize\)/);
assert.match(component, /document\.fullscreenElement === player/);
assert.doesNotMatch(component, /video\.video(?:Width|Height)/, "source dimensions must not resize the player stage");
assert.doesNotMatch(component, /ResizeObserver/, "player sizing must not create a resize-feedback loop while video starts");
assert.match(component, /if \(playerElement\.value === next\) return;/, "stable function refs must not rewrite player styles on every render");