From 84efd6ed010f32027ab8a5ea54949c17f31a6b37 Mon Sep 17 00:00:00 2001 From: Ami-OS Date: Fri, 13 Nov 2020 14:42:01 +0800 Subject: [PATCH] If thumbnails overflow the video area, center it --- src/plugin.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugin.js b/src/plugin.js index 055b45a..cb38ba0 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -287,7 +287,9 @@ class vttThumbnailsPlugin { const marginRight = width - (xPos + halfthumbnailWidth); const marginLeft = xPos - halfthumbnailWidth; - if (marginLeft > 0 && marginRight > 0) { + if (width < thumbnailWidth) { + this.thumbnailHolder.style.transform = 'translateX(' + (((thumbnailWidth - width) / 2) * -1) + 'px)'; + } else if (marginLeft > 0 && marginRight > 0) { this.thumbnailHolder.style.transform = 'translateX(' + (xPos - halfthumbnailWidth) + 'px)'; } else if (marginLeft <= 0) { this.thumbnailHolder.style.transform = 'translateX(' + 0 + 'px)';