From 8f9d7c984f8a541b25a49e01f7fd590c47569aff Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 24 Mar 2019 07:44:11 -0700 Subject: [PATCH] Fix image/video hover in case where dimensions are not available. #2197 --- src/Images/ImageHover.coffee | 20 +++++++++++--------- src/css/style.css | 4 ++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Images/ImageHover.coffee b/src/Images/ImageHover.coffee index fdce1854e..d9cd67149 100644 --- a/src/Images/ImageHover.coffee +++ b/src/Images/ImageHover.coffee @@ -46,20 +46,22 @@ ImageHover = if Conf['Autoplay'] el.play() @currentTime = el.currentTime if @nodeName is 'VIDEO' - [width, height] = (+x for x in file.dimensions.split 'x') - {left, right} = @getBoundingClientRect() - maxWidth = doc.clientWidth - maxHeight = doc.clientHeight - UI.hover.padding - scale = Math.min 1, maxWidth / width, maxHeight / height - el.style.maxWidth = "#{scale * width}px" - el.style.maxHeight = "#{scale * height}px" + if file.dimensions + [width, height] = (+x for x in file.dimensions.split 'x') + maxWidth = doc.clientWidth + maxHeight = doc.clientHeight - UI.hover.padding + scale = Math.min 1, maxWidth / width, maxHeight / height + width *= scale + height *= scale + el.style.maxWidth = "#{width}px" + el.style.maxHeight = "#{height}px" UI.hover root: @ el: el latestEvent: e endEvents: 'mouseout click' - height: scale * height - width: scale * width + height: height + width: width noRemove: true cb: -> $.off el, 'error', error diff --git a/src/css/style.css b/src/css/style.css index 29da2b593..4b176040b 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -1350,6 +1350,10 @@ span.hide-announcement { } #ihover { pointer-events: none; + /* XXX https://code.google.com/p/chromium/issues/detail?id=168840, https://bugs.webkit.org/show_bug.cgi?id=94158 */ + max-height: 95vh; + max-height: calc(100vh - 25px); + max-width: 100vw; } /* WEBM Metadata */ .webm-title > a::before {