refactor rewinding code and try to sync with thumbnails
This commit is contained in:
parent
95352b5bac
commit
d6fb7065e2
@ -65,7 +65,6 @@ class Clone extends Post
|
||||
|
||||
# Remove any #ihover ID
|
||||
@file.fullImage?.removeAttribute 'id'
|
||||
delete file.isHovered
|
||||
|
||||
@isDead = true if origin.isDead
|
||||
@isClone = true
|
||||
|
||||
@ -1,4 +1,15 @@
|
||||
ImageCommon =
|
||||
rewind: (post, el) ->
|
||||
{file} = post
|
||||
{thumb} = file
|
||||
if file.isVideo
|
||||
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
|
||||
|
||||
pushCache: (el) ->
|
||||
ImageCommon.cache = el
|
||||
$.on el, 'error', ImageCommon.cacheError
|
||||
|
||||
@ -142,6 +142,7 @@ ImageExpand =
|
||||
$.off el, eventName, cb
|
||||
$.rm el
|
||||
$.rmClass el, 'full-image'
|
||||
ImageCommon.rewind post, el
|
||||
ImageCommon.pushCache el
|
||||
|
||||
expand: (post, src) ->
|
||||
@ -157,9 +158,6 @@ ImageExpand =
|
||||
el = file.fullImage
|
||||
else if ImageCommon.cache?.dataset.fullID is post.fullID
|
||||
el = file.fullImage = ImageCommon.popCache()
|
||||
unless file.isHovered
|
||||
$.queueTask(-> el.src = el.src) if /\.gif$/.test el.src
|
||||
el.currentTime = 0 if isVideo and el.readyState >= el.HAVE_METADATA
|
||||
$.on el, 'error', ImageExpand.error
|
||||
else
|
||||
el = file.fullImage = $.el (if isVideo then 'video' else 'img')
|
||||
|
||||
@ -21,18 +21,16 @@ ImageHover =
|
||||
{file} = post
|
||||
{isVideo} = file
|
||||
return if file.isExpanding or file.isExpanded
|
||||
file.isHovered = true
|
||||
error = ImageHover.error post
|
||||
if ImageCommon.cache?.dataset.fullID is post.fullID
|
||||
el = ImageCommon.popCache()
|
||||
$.on el, 'error', error
|
||||
$.queueTask(-> el.src = el.src) if /\.gif$/.test el.src
|
||||
el.currentTime = 0 if isVideo and el.readyState >= el.HAVE_METADATA
|
||||
else
|
||||
el = $.el (if isVideo then 'video' else 'img')
|
||||
el.dataset.fullID = post.fullID
|
||||
$.on el, 'error', error
|
||||
el.src = file.URL
|
||||
ImageCommon.rewind post, el
|
||||
el.id = 'ihover'
|
||||
$.after Header.hover, el
|
||||
if isVideo
|
||||
@ -63,7 +61,6 @@ ImageHover =
|
||||
el.removeAttribute 'id'
|
||||
el.removeAttribute 'style'
|
||||
ImageCommon.pushCache el
|
||||
$.queueTask -> delete file.isHovered
|
||||
error: (post) -> ->
|
||||
return if ImageCommon.decodeError @, post
|
||||
ImageCommon.error @, post, 3 * $.SECOND, (URL) =>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user