work around FF forever-loading bug, other tweaks

This commit is contained in:
ccd0 2014-04-06 09:58:34 -07:00
parent 536abebe1f
commit d32b923ac5
5 changed files with 48 additions and 25 deletions

View File

@ -65,6 +65,10 @@
- Many spiffy performance, state awareness, and sanity improvements to JSON Navigation.
- Reload captcha if there are posts in the queue.
**ccd0**
- In v1.5.1, image/video hover was changed to hide and re-use the images/videos to avoid crashes.
Fixing bugs caused by this change.
### v1.5.2
*2014-04-04*

View File

@ -8075,10 +8075,7 @@
$.on(el, 'error', ImageExpand.error);
el.src = src || post.file.URL;
}
if (isVideo) {
el.controls = Conf['Show Controls'];
}
position = el.controls ? thumb.parentNode : thumb;
position = isVideo && Conf['Show Controls'] ? thumb.parentNode : thumb;
if (el !== position.nextSibling) {
$.after(position, el);
}
@ -8139,7 +8136,8 @@
video = file.fullImage;
file.videoControls = [];
video.muted = !Conf['Allow Sound'];
if (video.controls) {
video.controls = Conf['Show Controls'];
if (Conf['Show Controls']) {
contract = $.el('a', {
textContent: 'contract',
href: 'javascript:;',
@ -8157,8 +8155,18 @@
}
}
if (Conf['Autoplay']) {
video.controls = false;
video.play();
} else if (!video.controls) {
if (Conf['Show Controls']) {
$.asap((function() {
return (video.readyState >= 3 && video.currentTime <= Math.max(0.1, video.duration - 0.5)) || !file.isExpanded;
}), function() {
if (file.isExpanded) {
return video.controls = true;
}
}, 500);
}
} else if (!Conf['Show Controls']) {
play = $.el('a', {
textContent: 'play',
href: 'javascript:;'
@ -8292,7 +8300,7 @@
return $.on(this.nodes.thumb, 'mouseover', ImageHover.mouseover);
},
mouseover: function(e) {
var el, isVideo, naturalHeight, position, post, thumb;
var el, isVideo, position, post, thumb;
post = $.hasClass(this, 'thumb') ? g.posts[this.parentNode.dataset.fullID] : Get.postFromNode(this);
isVideo = post.file.isVideo;
if (post.file.fullImage) {
@ -8326,14 +8334,13 @@
el.play();
}
}
naturalHeight = post.file.isVideo ? 'videoHeight' : 'naturalHeight';
UI.hover({
root: this,
el: el,
latestEvent: e,
endEvents: 'mouseout click',
asapTest: function() {
return el[naturalHeight];
return isVideo || el.naturalHeight;
},
noRemove: true,
cb: function() {

View File

@ -8114,10 +8114,7 @@
$.on(el, 'error', ImageExpand.error);
el.src = src || post.file.URL;
}
if (isVideo) {
el.controls = Conf['Show Controls'];
}
position = el.controls ? thumb.parentNode : thumb;
position = isVideo && Conf['Show Controls'] ? thumb.parentNode : thumb;
if (el !== position.nextSibling) {
$.after(position, el);
}
@ -8178,7 +8175,8 @@
video = file.fullImage;
file.videoControls = [];
video.muted = !Conf['Allow Sound'];
if (video.controls) {
video.controls = Conf['Show Controls'];
if (Conf['Show Controls']) {
contract = $.el('a', {
textContent: 'contract',
href: 'javascript:;',
@ -8196,8 +8194,18 @@
}
}
if (Conf['Autoplay']) {
video.controls = false;
video.play();
} else if (!video.controls) {
if (Conf['Show Controls']) {
$.asap((function() {
return (video.readyState >= 3 && video.currentTime <= Math.max(0.1, video.duration - 0.5)) || !file.isExpanded;
}), function() {
if (file.isExpanded) {
return video.controls = true;
}
}, 500);
}
} else if (!Conf['Show Controls']) {
play = $.el('a', {
textContent: 'play',
href: 'javascript:;'
@ -8320,7 +8328,7 @@
return $.on(this.nodes.thumb, 'mouseover', ImageHover.mouseover);
},
mouseover: function(e) {
var el, isVideo, naturalHeight, position, post, thumb;
var el, isVideo, position, post, thumb;
post = $.hasClass(this, 'thumb') ? g.posts[this.parentNode.dataset.fullID] : Get.postFromNode(this);
isVideo = post.file.isVideo;
if (post.file.fullImage) {
@ -8354,14 +8362,13 @@
el.play();
}
}
naturalHeight = post.file.isVideo ? 'videoHeight' : 'naturalHeight';
UI.hover({
root: this,
el: el,
latestEvent: e,
endEvents: 'mouseout click',
asapTest: function() {
return el[naturalHeight];
return isVideo || el.naturalHeight;
},
noRemove: true,
cb: function() {

View File

@ -112,8 +112,7 @@ ImageExpand =
el.loop = true if isVideo
$.on el, 'error', ImageExpand.error
el.src = src or post.file.URL
el.controls = Conf['Show Controls'] if isVideo
position = if el.controls then thumb.parentNode else thumb
position = if isVideo and Conf['Show Controls'] then thumb.parentNode else thumb
$.after position, el unless el is position.nextSibling
$.asap (-> isVideo or el.naturalHeight), ->
ImageExpand.completeExpand post
@ -148,8 +147,9 @@ ImageExpand =
{file} = post
video = file.fullImage
file.videoControls = []
video.muted = not Conf['Allow Sound']
if video.controls
video.muted = !Conf['Allow Sound']
video.controls = Conf['Show Controls']
if Conf['Show Controls']
# contract link in file info
contract = $.el 'a',
textContent: 'contract'
@ -162,8 +162,14 @@ ImageExpand =
for eventName, cb of ImageExpand.videoCB
$.on video, eventName, cb
if Conf['Autoplay']
video.controls = false
video.play()
else unless video.controls
# Hacky workaround for Firefox forever-loading bug
if Conf['Show Controls']
$.asap (-> (video.readyState >= 3 and video.currentTime <= Math.max 0.1, (video.duration - 0.5)) or !file.isExpanded), ->
video.controls = true if file.isExpanded
, 500
else unless Conf['Show Controls']
play = $.el 'a',
textContent: 'play'
href: 'javascript:;'

View File

@ -41,13 +41,12 @@ ImageHover =
el.controls = false
el.muted = not Conf['Allow Sound']
el.play() if Conf['Autoplay']
naturalHeight = if post.file.isVideo then 'videoHeight' else 'naturalHeight'
UI.hover
root: @
el: el
latestEvent: e
endEvents: 'mouseout click'
asapTest: -> el[naturalHeight]
asapTest: -> (isVideo or el.naturalHeight)
noRemove: true
cb: ->
if isVideo