aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/js-components/previewBar.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/js-components/previewBar.ts')
-rw-r--r--src/js-components/previewBar.ts9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts
index af720568..fd7476a1 100644
--- a/src/js-components/previewBar.ts
+++ b/src/js-components/previewBar.ts
@@ -102,9 +102,10 @@ class PreviewBar {
let currentSegmentLength = Infinity;
for (const seg of this.segments) {
- if (seg.segment[0] <= timeInSeconds && seg.segment[1] > timeInSeconds) {
- const segmentLength = seg.segment[1] - seg.segment[0];
-
+ const segmentLength = seg.segment[1] - seg.segment[0];
+ const startTime = segmentLength !== 0 ? seg.segment[0] : Math.floor(seg.segment[0]);
+ const endTime = segmentLength !== 0 ? seg.segment[1] : Math.ceil(seg.segment[1]);
+ if (startTime <= timeInSeconds && endTime >= timeInSeconds) {
if (segmentLength < currentSegmentLength) {
currentSegmentLength = segmentLength;
segment = seg;
@@ -193,7 +194,7 @@ class PreviewBar {
if (!this.onMobileYouTube) bar.style.opacity = Config.config.barTypes[fullCategoryName]?.opacity;
bar.style.position = "absolute";
- bar.style.width = this.timeToPercentage(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]);
return bar;