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'] if Conf['Autoplay']
el.play() el.play()
@currentTime = el.currentTime if @nodeName is 'VIDEO' @currentTime = el.currentTime if @nodeName is 'VIDEO'
[width, height] = (+x for x in file.dimensions.split 'x') if file.dimensions
{left, right} = @getBoundingClientRect() [width, height] = (+x for x in file.dimensions.split 'x')
maxWidth = doc.clientWidth maxWidth = doc.clientWidth
maxHeight = doc.clientHeight - UI.hover.padding maxHeight = doc.clientHeight - UI.hover.padding
scale = Math.min 1, maxWidth / width, maxHeight / height scale = Math.min 1, maxWidth / width, maxHeight / height
el.style.maxWidth = "#{scale * width}px" width *= scale
el.style.maxHeight = "#{scale * height}px" height *= scale
el.style.maxWidth = "#{width}px"
el.style.maxHeight = "#{height}px"
UI.hover UI.hover
root: @ root: @
el: el el: el
latestEvent: e latestEvent: e
endEvents: 'mouseout click' endEvents: 'mouseout click'
height: scale * height height: height
width: scale * width width: width
noRemove: true noRemove: true
cb: -> cb: ->
$.off el, 'error', error $.off el, 'error', error

View File

@ -1350,6 +1350,10 @@ span.hide-announcement {
} }
#ihover { #ihover {
pointer-events: none; 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 Metadata */
.webm-title > a::before { .webm-title > a::before {