player breakpoint improvements
This commit is contained in:
@@ -67,9 +67,24 @@
|
||||
|
||||
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() {
|
||||
if (!browser) return;
|
||||
isMobile = window.matchMedia?.("(max-width: 1023px)")?.matches ?? false;
|
||||
const nextIsMobile =
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user