fix hover/expand so it works when switching between catalog/paged modes
Conflicts: builds/4chan-X.user.js builds/crx/script.js
This commit is contained in:
parent
0f770459c0
commit
52949b545e
@ -7695,38 +7695,36 @@
|
|||||||
return post.file.isExpanded = false;
|
return post.file.isExpanded = false;
|
||||||
},
|
},
|
||||||
expand: function(post, src) {
|
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;
|
_ref = post.file, thumb = _ref.thumb, isVideo = _ref.isVideo;
|
||||||
if (post.isHidden || post.file.isExpanded || $.hasClass(thumb, 'expanding')) {
|
if (post.isHidden || post.file.isExpanded || $.hasClass(thumb, 'expanding')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$.addClass(thumb, 'expanding');
|
$.addClass(thumb, 'expanding');
|
||||||
naturalHeight = isVideo ? 'videoHeight' : 'naturalHeight';
|
|
||||||
if (el = post.file.fullImage) {
|
if (el = post.file.fullImage) {
|
||||||
TrashQueue.remove(el);
|
TrashQueue.remove(el);
|
||||||
el.controls = el.parentNode !== thumb.parentNode;
|
} else {
|
||||||
$.asap((function() {
|
el = post.file.fullImage = $.el((isVideo ? 'video' : 'img'), {
|
||||||
return el[naturalHeight];
|
className: 'full-image',
|
||||||
}), function() {
|
src: src || post.file.URL
|
||||||
return ImageExpand.completeExpand(post);
|
|
||||||
});
|
});
|
||||||
return;
|
if (isVideo) {
|
||||||
|
el.loop = true;
|
||||||
|
}
|
||||||
|
$.on(el, 'error', ImageExpand.error);
|
||||||
}
|
}
|
||||||
post.file.fullImage = el = $.el((isVideo ? 'video' : 'img'), {
|
if (el.isVideo) {
|
||||||
className: 'full-image',
|
|
||||||
src: src || post.file.URL
|
|
||||||
});
|
|
||||||
if (isVideo) {
|
|
||||||
el.loop = true;
|
|
||||||
el.controls = Conf['Show Controls'];
|
el.controls = Conf['Show Controls'];
|
||||||
}
|
}
|
||||||
$.on(el, 'error', ImageExpand.error);
|
position = el.controls ? thumb.parentNode : thumb;
|
||||||
$.asap((function() {
|
if (el !== position.nextSibling) {
|
||||||
return post.file.fullImage[naturalHeight];
|
$.after(position, el);
|
||||||
|
}
|
||||||
|
return $.asap((function() {
|
||||||
|
return isVideo || el.naturalHeight;
|
||||||
}), function() {
|
}), function() {
|
||||||
return ImageExpand.completeExpand(post);
|
return ImageExpand.completeExpand(post);
|
||||||
});
|
});
|
||||||
return $.after((el.controls ? thumb.parentNode : thumb), el);
|
|
||||||
},
|
},
|
||||||
completeExpand: function(post) {
|
completeExpand: function(post) {
|
||||||
var bottom, thumb;
|
var bottom, thumb;
|
||||||
@ -7920,7 +7918,7 @@
|
|||||||
return $.on(this.file.thumb, 'mouseover', ImageHover.mouseover);
|
return $.on(this.file.thumb, 'mouseover', ImageHover.mouseover);
|
||||||
},
|
},
|
||||||
mouseover: function(e) {
|
mouseover: function(e) {
|
||||||
var el, isVideo, naturalHeight, post, thumb;
|
var el, isVideo, naturalHeight, position, post, thumb;
|
||||||
post = Get.postFromNode(this);
|
post = Get.postFromNode(this);
|
||||||
isVideo = post.file.isVideo;
|
isVideo = post.file.isVideo;
|
||||||
if (post.file.fullImage) {
|
if (post.file.fullImage) {
|
||||||
@ -7933,9 +7931,14 @@
|
|||||||
});
|
});
|
||||||
post.file.fullImage = el;
|
post.file.fullImage = el;
|
||||||
thumb = post.file.thumb;
|
thumb = post.file.thumb;
|
||||||
if (d.body.contains(thumb)) {
|
}
|
||||||
$.after((isVideo && Conf['Show Controls'] ? thumb.parentNode : thumb), el);
|
if (d.body.contains(thumb)) {
|
||||||
} else {
|
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);
|
$.add(Header.hover, el);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7714,38 +7714,36 @@
|
|||||||
return post.file.isExpanded = false;
|
return post.file.isExpanded = false;
|
||||||
},
|
},
|
||||||
expand: function(post, src) {
|
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;
|
_ref = post.file, thumb = _ref.thumb, isVideo = _ref.isVideo;
|
||||||
if (post.isHidden || post.file.isExpanded || $.hasClass(thumb, 'expanding')) {
|
if (post.isHidden || post.file.isExpanded || $.hasClass(thumb, 'expanding')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$.addClass(thumb, 'expanding');
|
$.addClass(thumb, 'expanding');
|
||||||
naturalHeight = isVideo ? 'videoHeight' : 'naturalHeight';
|
|
||||||
if (el = post.file.fullImage) {
|
if (el = post.file.fullImage) {
|
||||||
TrashQueue.remove(el);
|
TrashQueue.remove(el);
|
||||||
el.controls = el.parentNode !== thumb.parentNode;
|
} else {
|
||||||
$.asap((function() {
|
el = post.file.fullImage = $.el((isVideo ? 'video' : 'img'), {
|
||||||
return el[naturalHeight];
|
className: 'full-image',
|
||||||
}), function() {
|
src: src || post.file.URL
|
||||||
return ImageExpand.completeExpand(post);
|
|
||||||
});
|
});
|
||||||
return;
|
if (isVideo) {
|
||||||
|
el.loop = true;
|
||||||
|
}
|
||||||
|
$.on(el, 'error', ImageExpand.error);
|
||||||
}
|
}
|
||||||
post.file.fullImage = el = $.el((isVideo ? 'video' : 'img'), {
|
if (el.isVideo) {
|
||||||
className: 'full-image',
|
|
||||||
src: src || post.file.URL
|
|
||||||
});
|
|
||||||
if (isVideo) {
|
|
||||||
el.loop = true;
|
|
||||||
el.controls = Conf['Show Controls'];
|
el.controls = Conf['Show Controls'];
|
||||||
}
|
}
|
||||||
$.on(el, 'error', ImageExpand.error);
|
position = el.controls ? thumb.parentNode : thumb;
|
||||||
$.asap((function() {
|
if (el !== position.nextSibling) {
|
||||||
return post.file.fullImage[naturalHeight];
|
$.after(position, el);
|
||||||
|
}
|
||||||
|
return $.asap((function() {
|
||||||
|
return isVideo || el.naturalHeight;
|
||||||
}), function() {
|
}), function() {
|
||||||
return ImageExpand.completeExpand(post);
|
return ImageExpand.completeExpand(post);
|
||||||
});
|
});
|
||||||
return $.after((el.controls ? thumb.parentNode : thumb), el);
|
|
||||||
},
|
},
|
||||||
completeExpand: function(post) {
|
completeExpand: function(post) {
|
||||||
var bottom, thumb;
|
var bottom, thumb;
|
||||||
@ -7928,7 +7926,7 @@
|
|||||||
return $.on(this.file.thumb, 'mouseover', ImageHover.mouseover);
|
return $.on(this.file.thumb, 'mouseover', ImageHover.mouseover);
|
||||||
},
|
},
|
||||||
mouseover: function(e) {
|
mouseover: function(e) {
|
||||||
var el, isVideo, naturalHeight, post, thumb;
|
var el, isVideo, naturalHeight, position, post, thumb;
|
||||||
post = Get.postFromNode(this);
|
post = Get.postFromNode(this);
|
||||||
isVideo = post.file.isVideo;
|
isVideo = post.file.isVideo;
|
||||||
if (post.file.fullImage) {
|
if (post.file.fullImage) {
|
||||||
@ -7941,9 +7939,14 @@
|
|||||||
});
|
});
|
||||||
post.file.fullImage = el;
|
post.file.fullImage = el;
|
||||||
thumb = post.file.thumb;
|
thumb = post.file.thumb;
|
||||||
if (d.body.contains(thumb)) {
|
}
|
||||||
$.after((isVideo && Conf['Show Controls'] ? thumb.parentNode : thumb), el);
|
if (d.body.contains(thumb)) {
|
||||||
} else {
|
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);
|
$.add(Header.hover, el);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,24 +106,20 @@ ImageExpand =
|
|||||||
{thumb, isVideo} = post.file
|
{thumb, isVideo} = post.file
|
||||||
return if post.isHidden or post.file.isExpanded or $.hasClass thumb, 'expanding'
|
return if post.isHidden or post.file.isExpanded or $.hasClass thumb, 'expanding'
|
||||||
$.addClass thumb, 'expanding'
|
$.addClass thumb, 'expanding'
|
||||||
naturalHeight = if isVideo then 'videoHeight' else 'naturalHeight'
|
|
||||||
if el = post.file.fullImage
|
if el = post.file.fullImage
|
||||||
# Expand already-loaded/ing picture.
|
# Expand already-loaded/ing picture.
|
||||||
TrashQueue.remove el
|
TrashQueue.remove el
|
||||||
el.controls = (el.parentNode isnt thumb.parentNode)
|
else
|
||||||
$.asap (-> el[naturalHeight]), ->
|
el = post.file.fullImage = $.el (if isVideo then 'video' else 'img'),
|
||||||
ImageExpand.completeExpand post
|
className: 'full-image'
|
||||||
return
|
src: src or post.file.URL
|
||||||
post.file.fullImage = el = $.el (if isVideo then 'video' else 'img'),
|
el.loop = true if isVideo
|
||||||
className: 'full-image'
|
$.on el, 'error', ImageExpand.error
|
||||||
src: src or post.file.URL
|
el.controls = Conf['Show Controls'] if el.isVideo
|
||||||
if isVideo
|
position = if el.controls then thumb.parentNode else thumb
|
||||||
el.loop = true
|
$.after position, el unless el is position.nextSibling
|
||||||
el.controls = Conf['Show Controls']
|
$.asap (-> isVideo or el.naturalHeight), ->
|
||||||
$.on el, 'error', ImageExpand.error
|
|
||||||
$.asap (-> post.file.fullImage[naturalHeight]), ->
|
|
||||||
ImageExpand.completeExpand post
|
ImageExpand.completeExpand post
|
||||||
$.after (if el.controls then thumb.parentNode else thumb), el
|
|
||||||
|
|
||||||
completeExpand: (post) ->
|
completeExpand: (post) ->
|
||||||
{thumb} = post.file
|
{thumb} = post.file
|
||||||
|
|||||||
@ -20,10 +20,11 @@ ImageHover =
|
|||||||
src: post.file.URL
|
src: post.file.URL
|
||||||
post.file.fullImage = el
|
post.file.fullImage = el
|
||||||
{thumb} = post.file
|
{thumb} = post.file
|
||||||
if d.body.contains thumb
|
if d.body.contains thumb
|
||||||
$.after (if isVideo and Conf['Show Controls'] then thumb.parentNode else thumb), el
|
position = if isVideo and Conf['Show Controls'] then thumb.parentNode else thumb
|
||||||
else
|
$.after position, el unless el is position.nextSibling
|
||||||
$.add Header.hover, el
|
else
|
||||||
|
$.add Header.hover, el if el.parentNode isnt Header.hover
|
||||||
el.id = 'ihover'
|
el.id = 'ihover'
|
||||||
el.dataset.fullID = post.fullID
|
el.dataset.fullID = post.fullID
|
||||||
if isVideo
|
if isVideo
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user