diff options
author | Ajay Ramachandran <[email protected]> | 2021-11-16 23:26:15 -0500 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2021-11-16 23:26:15 -0500 |
commit | 96693342a3fbae8a3f80a4ef28137dbdb42f52ee (patch) | |
tree | 3da1f7d2e00839c33cfb62f6187f0d8f72c36458 | |
parent | 06da4d6556a386be783984f840ab86e6333f6759 (diff) | |
download | SponsorBlock-96693342a3fbae8a3f80a4ef28137dbdb42f52ee.tar.gz SponsorBlock-96693342a3fbae8a3f80a4ef28137dbdb42f52ee.zip |
Fix start time messing up when end time too far in preview bar
-rw-r--r-- | src/js-components/previewBar.ts | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts index 5ef5f822..4e840646 100644 --- a/src/js-components/previewBar.ts +++ b/src/js-components/previewBar.ts @@ -197,10 +197,10 @@ 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]); + const duration = Math.min(segment[1], this.videoDuration) - segment[0]; + if (duration > 0) bar.style.width = this.timeToPercentage(duration); - const time = segment[1] ? Math.min(this.videoDuration - Math.max(0, duration), segment[0]) : segment[0]; + const time = segment[1] ? Math.min(this.videoDuration, segment[0]) : segment[0]; bar.style.left = this.timeToPercentage(time); return bar; |