fix: align subtitle sidebar state and behavior updates

This commit is contained in:
2026-03-21 22:24:42 -07:00
parent 4c6e4b9f0b
commit 5ea064a446
12 changed files with 34 additions and 17 deletions

View File

@@ -145,6 +145,7 @@ export function createSubtitleSidebarModal(
let snapshotPollInterval: ReturnType<typeof setTimeout> | null = null;
let lastAppliedVideoMarginRatio: number | null = null;
let subtitleSidebarHoverRequestId = 0;
let disposeDomEvents: (() => void) | null = null;
function restoreEmbeddedSidebarPassthrough(): void {
syncOverlayMouseIgnoreState(ctx);
@@ -515,6 +516,10 @@ export function createSubtitleSidebarModal(
}
function wireDomEvents(): void {
if (disposeDomEvents) {
return;
}
ctx.dom.subtitleSidebarClose.addEventListener('click', () => {
closeSubtitleSidebarModal();
});
@@ -565,12 +570,17 @@ export function createSubtitleSidebarModal(
ctx.state.isOverSubtitleSidebar = false;
resumeSubtitleSidebarHoverPause();
});
window.addEventListener('resize', () => {
const resizeHandler = () => {
if (!ctx.state.subtitleSidebarModalOpen) {
return;
}
syncEmbeddedSidebarLayout();
});
};
window.addEventListener('resize', resizeHandler);
disposeDomEvents = () => {
window.removeEventListener('resize', resizeHandler);
disposeDomEvents = null;
};
}
return {
@@ -580,6 +590,9 @@ export function createSubtitleSidebarModal(
toggleSubtitleSidebarModal,
refreshSubtitleSidebarSnapshot: refreshSnapshot,
wireDomEvents,
disposeDomEvents: () => {
disposeDomEvents?.();
},
handleSubtitleUpdated,
seekToCue,
};