mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-09-19 20:51:28 +02:00
Fix preview bar end time sometimes being inaccurate
This commit is contained in:
parent
16f27e5c5c
commit
e7d55d2bac
1 changed files with 6 additions and 1 deletions
|
@ -274,6 +274,7 @@ class PreviewBar {
|
||||||
return (b[1] - b[0]) - (a[1] - a[0]);
|
return (b[1] - b[0]) - (a[1] - a[0]);
|
||||||
});
|
});
|
||||||
for (const segment of sortedSegments) {
|
for (const segment of sortedSegments) {
|
||||||
|
if (segment.actionType === ActionType.Chapter) continue;
|
||||||
const bar = this.createBar(segment);
|
const bar = this.createBar(segment);
|
||||||
|
|
||||||
this.container.appendChild(bar);
|
this.container.appendChild(bar);
|
||||||
|
@ -313,7 +314,7 @@ class PreviewBar {
|
||||||
bar.style.left = this.timeToPercentage(startTime);
|
bar.style.left = this.timeToPercentage(startTime);
|
||||||
|
|
||||||
if (duration > 0) {
|
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) {
|
if (this.chapterFilter(barSegment) && segment[1] < this.videoDuration) {
|
||||||
bar.style.marginRight = `${this.chapterMargin}px`;
|
bar.style.marginRight = `${this.chapterMargin}px`;
|
||||||
|
@ -886,6 +887,10 @@ class PreviewBar {
|
||||||
return `${this.timeToDecimal(time) * 100}%`
|
return `${this.timeToDecimal(time) * 100}%`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timeToRightPercentage(time: number): string {
|
||||||
|
return `${(1 - this.timeToDecimal(time)) * 100}%`
|
||||||
|
}
|
||||||
|
|
||||||
timeToDecimal(time: number): number {
|
timeToDecimal(time: number): number {
|
||||||
return this.decimalTimeConverter(time, true);
|
return this.decimalTimeConverter(time, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue