diff options
author | Sam Potts <sam@potts.es> | 2020-02-10 11:26:53 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-10 11:26:53 +0000 |
commit | 74e5c78b3fed59636792cee8bdd0e711afa45548 (patch) | |
tree | fdd50a5b13b6e520d010ccaaee4862f08db7db41 /src/js | |
parent | e50b35d195316a1aee28797de26b3d7b42daa0be (diff) | |
parent | 97f8093a8df1fd7462512d43716bcd7601fecb18 (diff) | |
download | plyr-74e5c78b3fed59636792cee8bdd0e711afa45548.tar.lz plyr-74e5c78b3fed59636792cee8bdd0e711afa45548.tar.xz plyr-74e5c78b3fed59636792cee8bdd0e711afa45548.zip |
Merge pull request #1678 from ydylla/fix-thumb-size-per-css
Improve thumbnail size calculations when size is set per css
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/plugins/preview-thumbnails.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/js/plugins/preview-thumbnails.js b/src/js/plugins/preview-thumbnails.js index 6cd09ef2..e5378bd3 100644 --- a/src/js/plugins/preview-thumbnails.js +++ b/src/js/plugins/preview-thumbnails.js @@ -561,6 +561,11 @@ class PreviewThumbnails { return height; } + // If css is used this needs to return the css height for sprites to work (see setImageSizeAndOffset) + if (this.sizeSpecifiedInCSS) { + return this.elements.thumb.imageContainer.clientHeight; + } + return Math.floor(this.player.media.clientWidth / this.thumbAspectRatio / 4); } @@ -601,7 +606,7 @@ class PreviewThumbnails { } determineContainerAutoSizing() { - if (this.elements.thumb.imageContainer.clientHeight > 20) { + if (this.elements.thumb.imageContainer.clientHeight > 20 || this.elements.thumb.imageContainer.clientWidth > 20) { // This will prevent auto sizing in this.setThumbContainerSizeAndPos() this.sizeSpecifiedInCSS = true; } @@ -613,6 +618,12 @@ class PreviewThumbnails { const thumbWidth = Math.floor(this.thumbContainerHeight * this.thumbAspectRatio); this.elements.thumb.imageContainer.style.height = `${this.thumbContainerHeight}px`; this.elements.thumb.imageContainer.style.width = `${thumbWidth}px`; + } else if (this.elements.thumb.imageContainer.clientHeight > 20 && this.elements.thumb.imageContainer.clientWidth < 20) { + const thumbWidth = Math.floor(this.elements.thumb.imageContainer.clientHeight * this.thumbAspectRatio); + this.elements.thumb.imageContainer.style.width = `${thumbWidth}px`; + } else if (this.elements.thumb.imageContainer.clientHeight < 20 && this.elements.thumb.imageContainer.clientWidth > 20) { + const thumbHeight = Math.floor(this.elements.thumb.imageContainer.clientWidth / this.thumbAspectRatio); + this.elements.thumb.imageContainer.style.height = `${thumbHeight}px`; } this.setThumbContainerPos(); |