player breakpoint improvements
This commit is contained in:
@@ -67,9 +67,24 @@
|
|||||||
|
|
||||||
let unsubscribe: (() => void) | null = null;
|
let unsubscribe: (() => void) | null = null;
|
||||||
|
|
||||||
|
// Track breakpoint transitions so we can auto open/close on crossing:
|
||||||
|
// - desktop -> mobile: auto close
|
||||||
|
// - mobile -> desktop: auto open
|
||||||
|
let prevIsMobile: boolean | null = $state(null);
|
||||||
|
|
||||||
function updateIsMobile() {
|
function updateIsMobile() {
|
||||||
if (!browser) return;
|
const nextIsMobile =
|
||||||
isMobile = window.matchMedia?.("(max-width: 1023px)")?.matches ?? false;
|
window.matchMedia?.("(max-width: 1023px)")?.matches ?? false;
|
||||||
|
|
||||||
|
// Update local derived flag
|
||||||
|
isMobile = nextIsMobile;
|
||||||
|
|
||||||
|
// On transitions, sync player UI open state
|
||||||
|
if (prevIsMobile !== null && prevIsMobile !== nextIsMobile) {
|
||||||
|
setUiOpen(!nextIsMobile);
|
||||||
|
}
|
||||||
|
|
||||||
|
prevIsMobile = nextIsMobile;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Media Session bindings
|
// Media Session bindings
|
||||||
|
|||||||
Reference in New Issue
Block a user