better approach to rewinding, and restore rewind on expand if not from hover
This commit is contained in:
parent
cb50f17567
commit
6c9757632f
@ -1,14 +1,9 @@
|
||||
ImageCommon =
|
||||
rewind: (post, el) ->
|
||||
{file} = post
|
||||
{thumb} = file
|
||||
if file.isVideo
|
||||
rewind: (el) ->
|
||||
if el.nodeName is 'VIDEO'
|
||||
el.currentTime = 0 if el.readyState >= el.HAVE_METADATA
|
||||
thumb.currentTime = 0 if file.videoThumb and thumb.readyState >= thumb.HAVE_METADATA
|
||||
else if /\.gif$/.test el.src
|
||||
$.queueTask ->
|
||||
el.src = el.src
|
||||
thumb.src = thumb.src
|
||||
$.queueTask -> el.src = el.src
|
||||
|
||||
pushCache: (el) ->
|
||||
ImageCommon.cache = el
|
||||
|
||||
@ -140,7 +140,7 @@ ImageExpand =
|
||||
el.pause()
|
||||
for eventName, cb of ImageExpand.videoCB
|
||||
$.off el, eventName, cb
|
||||
ImageCommon.rewind post, el
|
||||
ImageCommon.rewind file.thumb
|
||||
delete file.fullImage
|
||||
$.queueTask ->
|
||||
# XXX Work around Chrome/Chromium not firing mouseover on the thumbnail.
|
||||
@ -163,6 +163,8 @@ ImageExpand =
|
||||
else if ImageCommon.cache?.dataset.fullID is post.fullID
|
||||
el = file.fullImage = ImageCommon.popCache()
|
||||
$.on el, 'error', ImageExpand.error
|
||||
ImageCommon.rewind el unless el.id is 'ihover'
|
||||
el.removeAttribute 'id'
|
||||
else
|
||||
el = file.fullImage = $.el (if isVideo then 'video' else 'img')
|
||||
el.dataset.fullID = post.fullID
|
||||
|
||||
@ -30,7 +30,8 @@ ImageHover =
|
||||
el.dataset.fullID = post.fullID
|
||||
$.on el, 'error', error
|
||||
el.src = file.URL
|
||||
ImageCommon.rewind post, el
|
||||
ImageCommon.rewind el
|
||||
ImageCommon.rewind @
|
||||
el.id = 'ihover'
|
||||
$.after Header.hover, el
|
||||
if isVideo
|
||||
@ -58,7 +59,6 @@ ImageHover =
|
||||
ImageCommon.pushCache el
|
||||
el.pause() if isVideo
|
||||
$.rm el
|
||||
el.removeAttribute 'id'
|
||||
el.removeAttribute 'style'
|
||||
error: (post) -> ->
|
||||
return if ImageCommon.decodeError @, post
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user