Fix image/video hover in case where dimensions are not available. #2197

This commit is contained in:
ccd0 2019-03-24 07:44:11 -07:00
parent 501a103a1d
commit 8f9d7c984f
2 changed files with 15 additions and 9 deletions

View File

@ -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

View File

@ -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 {