diff --git a/src/General/UI.coffee b/src/General/UI.coffee index fa30d32d6..7cf485b4b 100755 --- a/src/General/UI.coffee +++ b/src/General/UI.coffee @@ -302,7 +302,7 @@ UI = do -> $.off d, 'mouseup', @up $.set "#{@id}.position", @style.cssText - hoverstart = ({root, el, latestEvent, endEvents, asapTest, cb, noRemove}) -> + hoverstart = ({root, el, latestEvent, endEvents, asapTest, height, cb, noRemove}) -> o = { root el @@ -313,6 +313,7 @@ UI = do -> latestEvent clientHeight: doc.clientHeight clientWidth: doc.clientWidth + height noRemove } o.hover = hover.bind o @@ -335,7 +336,7 @@ UI = do -> hover = (e) -> @latestEvent = e - height = @el.offsetHeight + height = @height or @el.offsetHeight {clientX, clientY} = e top = if @isImage diff --git a/src/General/css/style.css b/src/General/css/style.css index 33473d649..e538018f6 100755 --- a/src/General/css/style.css +++ b/src/General/css/style.css @@ -837,13 +837,6 @@ span.hide-announcement { .fileThumb > .warning { clear: both; } -#ihover { - -moz-box-sizing: border-box; - box-sizing: border-box; - max-height: 100%; - max-width: 75%; - padding-bottom: 16px; -} /* Fappe Tyme */ :root.fappeTyme .thread > .noFile, :root.fappeTyme .threadContainer > .noFile { diff --git a/src/Images/ImageHover.coffee b/src/Images/ImageHover.coffee index 2cca594b2..ad4536d4b 100755 --- a/src/Images/ImageHover.coffee +++ b/src/Images/ImageHover.coffee @@ -31,18 +31,28 @@ ImageHover = el.loop = true el.controls = false el.play() if Conf['Autoplay'] + [width, height] = file.dimensions.split('x').map (x) -> +x + {left, right} = file.thumb.getBoundingClientRect() + padding = 16 + maxWidth = Math.max left, doc.clientWidth - right + maxHeight = doc.clientHeight - padding + scale = Math.min 1, maxWidth / width, maxHeight / height + el.style.maxWidth = "#{scale * width}px" + el.style.maxHeight = "#{scale * height}px" UI.hover root: @ el: el latestEvent: e endEvents: 'mouseout click' - asapTest: -> (if isVideo then el.readyState >= el.HAVE_CURRENT_DATA else el.naturalHeight) + asapTest: -> true + height: scale * height + padding noRemove: true cb: -> if isVideo el.pause() TrashQueue.add el, post el.removeAttribute 'id' + el.removeAttribute 'style' $.queueTask -> delete file.isHovered error: -> post = Get.postFromNode @