Skip to content

Commit

Permalink
Fix duration text width update on fullscreen change
Browse files Browse the repository at this point in the history
  • Loading branch information
hanydd committed Jan 30, 2024
1 parent 37c399e commit d3034cb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2567,14 +2567,20 @@ function showTimeWithoutSkips(skippedDuration: number): void {

const durationAfterSkips = getFormattedTime(getVideo()?.duration - skippedDuration);

if (durationAfterSkips != null && skippedDuration > 0) {
duration.innerText = " (" + durationAfterSkips + ")";

const refreshDurationTextWidth = () => {
// some hacks to change the min-width of the time control area,
// so it won't overlap with chapters on the right
display.style.width = "auto";
display.parentElement.style.minWidth = `${display.clientWidth - 11}px`;
}

if (durationAfterSkips != null && skippedDuration > 0) {
duration.innerText = " (" + durationAfterSkips + ")";

refreshDurationTextWidth();
// re-calculate text position after entering and exiting full screen
window.addEventListener("fullscreenchange", refreshDurationTextWidth);
}
}

function checkForPreloadedSegment() {
Expand Down

0 comments on commit d3034cb

Please sign in to comment.