mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 09:07:45 +01:00
Define left + right on previewbar segments instead of left + width
This commit is contained in:
parent
5711e70dbb
commit
0001d28f14
1 changed files with 28 additions and 25 deletions
|
@ -337,13 +337,16 @@ class PreviewBar {
|
||||||
|
|
||||||
bar.style.position = "absolute";
|
bar.style.position = "absolute";
|
||||||
const duration = Math.min(segment[1], this.videoDuration) - segment[0];
|
const duration = Math.min(segment[1], this.videoDuration) - segment[0];
|
||||||
if (duration > 0) {
|
const startTime = segment[1] ? Math.min(this.videoDuration, segment[0]) : segment[0];
|
||||||
bar.style.width = `calc(${this.intervalToPercentage(segment[0], segment[1])}${
|
const endTime = Math.min(this.videoDuration, segment[1]);
|
||||||
this.chapterFilter(barSegment) && segment[1] < this.videoDuration ? ` - ${this.chapterMargin}px` : ''})`;
|
bar.style.left = this.timeToPercentage(startTime);
|
||||||
}
|
|
||||||
|
|
||||||
const time = segment[1] ? Math.min(this.videoDuration, segment[0]) : segment[0];
|
if (duration > 0) {
|
||||||
bar.style.left = this.timeToPercentage(time);
|
bar.style.right = this.timeToPercentage(this.videoDuration - endTime);
|
||||||
|
}
|
||||||
|
if (this.chapterFilter(barSegment) && segment[1] < this.videoDuration) {
|
||||||
|
bar.style.marginRight = `${this.chapterMargin}px`;
|
||||||
|
}
|
||||||
|
|
||||||
return bar;
|
return bar;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue