From 4bc180077ef6c08b25f85b4fff1c13f9ca86a65d Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sat, 16 Oct 2021 13:15:47 -0400 Subject: [PATCH] Fix segments sometimes displaying after the seek bar if at the end --- src/js-components/previewBar.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts index 191053b9..c515ec85 100644 --- a/src/js-components/previewBar.ts +++ b/src/js-components/previewBar.ts @@ -197,8 +197,9 @@ class PreviewBar { if (!this.onMobileYouTube) bar.style.opacity = Config.config.barTypes[fullCategoryName]?.opacity; bar.style.position = "absolute"; + const duration = segment[1] - segment[0]; if (segment[1] - segment[0] > 0) bar.style.width = this.timeToPercentage(segment[1] - segment[0]); - bar.style.left = this.timeToPercentage(segment[0]); + bar.style.left = this.timeToPercentage(Math.min(this.videoDuration - Math.max(0, duration), segment[0])); return bar; }