diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index c4df67947..ca7ab4d3a 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -7695,38 +7695,36 @@ return post.file.isExpanded = false; }, expand: function(post, src) { - var el, isVideo, naturalHeight, thumb, _ref; + var el, isVideo, position, thumb, _ref; _ref = post.file, thumb = _ref.thumb, isVideo = _ref.isVideo; if (post.isHidden || post.file.isExpanded || $.hasClass(thumb, 'expanding')) { return; } $.addClass(thumb, 'expanding'); - naturalHeight = isVideo ? 'videoHeight' : 'naturalHeight'; if (el = post.file.fullImage) { TrashQueue.remove(el); - el.controls = el.parentNode !== thumb.parentNode; - $.asap((function() { - return el[naturalHeight]; - }), function() { - return ImageExpand.completeExpand(post); + } else { + el = post.file.fullImage = $.el((isVideo ? 'video' : 'img'), { + className: 'full-image', + src: src || post.file.URL }); - return; + if (isVideo) { + el.loop = true; + } + $.on(el, 'error', ImageExpand.error); } - post.file.fullImage = el = $.el((isVideo ? 'video' : 'img'), { - className: 'full-image', - src: src || post.file.URL - }); - if (isVideo) { - el.loop = true; + if (el.isVideo) { el.controls = Conf['Show Controls']; } - $.on(el, 'error', ImageExpand.error); - $.asap((function() { - return post.file.fullImage[naturalHeight]; + position = el.controls ? thumb.parentNode : thumb; + if (el !== position.nextSibling) { + $.after(position, el); + } + return $.asap((function() { + return isVideo || el.naturalHeight; }), function() { return ImageExpand.completeExpand(post); }); - return $.after((el.controls ? thumb.parentNode : thumb), el); }, completeExpand: function(post) { var bottom, thumb; @@ -7920,7 +7918,7 @@ return $.on(this.file.thumb, 'mouseover', ImageHover.mouseover); }, mouseover: function(e) { - var el, isVideo, naturalHeight, post, thumb; + var el, isVideo, naturalHeight, position, post, thumb; post = Get.postFromNode(this); isVideo = post.file.isVideo; if (post.file.fullImage) { @@ -7933,9 +7931,14 @@ }); post.file.fullImage = el; thumb = post.file.thumb; - if (d.body.contains(thumb)) { - $.after((isVideo && Conf['Show Controls'] ? thumb.parentNode : thumb), el); - } else { + } + if (d.body.contains(thumb)) { + position = isVideo && Conf['Show Controls'] ? thumb.parentNode : thumb; + if (el !== position.nextSibling) { + $.after(position, el); + } + } else { + if (el.parentNode !== Header.hover) { $.add(Header.hover, el); } } diff --git a/builds/crx/script.js b/builds/crx/script.js index 437c490fe..abf036066 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -7714,38 +7714,36 @@ return post.file.isExpanded = false; }, expand: function(post, src) { - var el, isVideo, naturalHeight, thumb, _ref; + var el, isVideo, position, thumb, _ref; _ref = post.file, thumb = _ref.thumb, isVideo = _ref.isVideo; if (post.isHidden || post.file.isExpanded || $.hasClass(thumb, 'expanding')) { return; } $.addClass(thumb, 'expanding'); - naturalHeight = isVideo ? 'videoHeight' : 'naturalHeight'; if (el = post.file.fullImage) { TrashQueue.remove(el); - el.controls = el.parentNode !== thumb.parentNode; - $.asap((function() { - return el[naturalHeight]; - }), function() { - return ImageExpand.completeExpand(post); + } else { + el = post.file.fullImage = $.el((isVideo ? 'video' : 'img'), { + className: 'full-image', + src: src || post.file.URL }); - return; + if (isVideo) { + el.loop = true; + } + $.on(el, 'error', ImageExpand.error); } - post.file.fullImage = el = $.el((isVideo ? 'video' : 'img'), { - className: 'full-image', - src: src || post.file.URL - }); - if (isVideo) { - el.loop = true; + if (el.isVideo) { el.controls = Conf['Show Controls']; } - $.on(el, 'error', ImageExpand.error); - $.asap((function() { - return post.file.fullImage[naturalHeight]; + position = el.controls ? thumb.parentNode : thumb; + if (el !== position.nextSibling) { + $.after(position, el); + } + return $.asap((function() { + return isVideo || el.naturalHeight; }), function() { return ImageExpand.completeExpand(post); }); - return $.after((el.controls ? thumb.parentNode : thumb), el); }, completeExpand: function(post) { var bottom, thumb; @@ -7928,7 +7926,7 @@ return $.on(this.file.thumb, 'mouseover', ImageHover.mouseover); }, mouseover: function(e) { - var el, isVideo, naturalHeight, post, thumb; + var el, isVideo, naturalHeight, position, post, thumb; post = Get.postFromNode(this); isVideo = post.file.isVideo; if (post.file.fullImage) { @@ -7941,9 +7939,14 @@ }); post.file.fullImage = el; thumb = post.file.thumb; - if (d.body.contains(thumb)) { - $.after((isVideo && Conf['Show Controls'] ? thumb.parentNode : thumb), el); - } else { + } + if (d.body.contains(thumb)) { + position = isVideo && Conf['Show Controls'] ? thumb.parentNode : thumb; + if (el !== position.nextSibling) { + $.after(position, el); + } + } else { + if (el.parentNode !== Header.hover) { $.add(Header.hover, el); } } diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index e30153398..72637b0fd 100755 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -106,24 +106,20 @@ ImageExpand = {thumb, isVideo} = post.file return if post.isHidden or post.file.isExpanded or $.hasClass thumb, 'expanding' $.addClass thumb, 'expanding' - naturalHeight = if isVideo then 'videoHeight' else 'naturalHeight' if el = post.file.fullImage # Expand already-loaded/ing picture. TrashQueue.remove el - el.controls = (el.parentNode isnt thumb.parentNode) - $.asap (-> el[naturalHeight]), -> - ImageExpand.completeExpand post - return - post.file.fullImage = el = $.el (if isVideo then 'video' else 'img'), - className: 'full-image' - src: src or post.file.URL - if isVideo - el.loop = true - el.controls = Conf['Show Controls'] - $.on el, 'error', ImageExpand.error - $.asap (-> post.file.fullImage[naturalHeight]), -> + else + el = post.file.fullImage = $.el (if isVideo then 'video' else 'img'), + className: 'full-image' + src: src or post.file.URL + el.loop = true if isVideo + $.on el, 'error', ImageExpand.error + el.controls = Conf['Show Controls'] if el.isVideo + position = if el.controls then thumb.parentNode else thumb + $.after position, el unless el is position.nextSibling + $.asap (-> isVideo or el.naturalHeight), -> ImageExpand.completeExpand post - $.after (if el.controls then thumb.parentNode else thumb), el completeExpand: (post) -> {thumb} = post.file diff --git a/src/Images/ImageHover.coffee b/src/Images/ImageHover.coffee index 1bc37357d..4a397b459 100755 --- a/src/Images/ImageHover.coffee +++ b/src/Images/ImageHover.coffee @@ -20,10 +20,11 @@ ImageHover = src: post.file.URL post.file.fullImage = el {thumb} = post.file - if d.body.contains thumb - $.after (if isVideo and Conf['Show Controls'] then thumb.parentNode else thumb), el - else - $.add Header.hover, el + if d.body.contains thumb + position = if isVideo and Conf['Show Controls'] then thumb.parentNode else thumb + $.after position, el unless el is position.nextSibling + else + $.add Header.hover, el if el.parentNode isnt Header.hover el.id = 'ihover' el.dataset.fullID = post.fullID if isVideo