diff options
author | Ajay <[email protected]> | 2024-01-25 19:38:10 -0500 |
---|---|---|
committer | Ajay <[email protected]> | 2024-01-25 19:38:10 -0500 |
commit | e7d55d2bac9575624c24e9272bbc1bf890b3b4d3 (patch) | |
tree | b0c6ef82eed9ebfc666998b4670160dd0f2037e3 | |
parent | 16f27e5c5cd3a8f99773fd232dd8f1689ecc9bbd (diff) | |
download | SponsorBlock-e7d55d2bac9575624c24e9272bbc1bf890b3b4d3.tar.gz SponsorBlock-e7d55d2bac9575624c24e9272bbc1bf890b3b4d3.zip |
Fix preview bar end time sometimes being inaccurate
-rw-r--r-- | src/js-components/previewBar.ts | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts index ef5d1045..5e002fb9 100644 --- a/src/js-components/previewBar.ts +++ b/src/js-components/previewBar.ts @@ -274,6 +274,7 @@ class PreviewBar { return (b[1] - b[0]) - (a[1] - a[0]); }); for (const segment of sortedSegments) { + if (segment.actionType === ActionType.Chapter) continue; const bar = this.createBar(segment); this.container.appendChild(bar); @@ -313,7 +314,7 @@ class PreviewBar { bar.style.left = this.timeToPercentage(startTime); if (duration > 0) { - bar.style.right = this.timeToPercentage(this.videoDuration - endTime); + bar.style.right = this.timeToRightPercentage(endTime); } if (this.chapterFilter(barSegment) && segment[1] < this.videoDuration) { bar.style.marginRight = `${this.chapterMargin}px`; @@ -886,6 +887,10 @@ class PreviewBar { return `${this.timeToDecimal(time) * 100}%` } + timeToRightPercentage(time: number): string { + return `${(1 - this.timeToDecimal(time)) * 100}%` + } + timeToDecimal(time: number): number { return this.decimalTimeConverter(time, true); } |