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