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
|
# Remove any #ihover ID
|
||||||
@file.fullImage?.removeAttribute 'id'
|
@file.fullImage?.removeAttribute 'id'
|
||||||
delete file.isHovered
|
|
||||||
|
|
||||||
@isDead = true if origin.isDead
|
@isDead = true if origin.isDead
|
||||||
@isClone = true
|
@isClone = true
|
||||||
|
|||||||
@ -1,4 +1,15 @@
|
|||||||
ImageCommon =
|
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) ->
|
pushCache: (el) ->
|
||||||
ImageCommon.cache = el
|
ImageCommon.cache = el
|
||||||
$.on el, 'error', ImageCommon.cacheError
|
$.on el, 'error', ImageCommon.cacheError
|
||||||
|
|||||||
@ -142,6 +142,7 @@ ImageExpand =
|
|||||||
$.off el, eventName, cb
|
$.off el, eventName, cb
|
||||||
$.rm el
|
$.rm el
|
||||||
$.rmClass el, 'full-image'
|
$.rmClass el, 'full-image'
|
||||||
|
ImageCommon.rewind post, el
|
||||||
ImageCommon.pushCache el
|
ImageCommon.pushCache el
|
||||||
|
|
||||||
expand: (post, src) ->
|
expand: (post, src) ->
|
||||||
@ -157,9 +158,6 @@ ImageExpand =
|
|||||||
el = file.fullImage
|
el = file.fullImage
|
||||||
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()
|
||||||
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
|
$.on el, 'error', ImageExpand.error
|
||||||
else
|
else
|
||||||
el = file.fullImage = $.el (if isVideo then 'video' else 'img')
|
el = file.fullImage = $.el (if isVideo then 'video' else 'img')
|
||||||
|
|||||||
@ -21,18 +21,16 @@ ImageHover =
|
|||||||
{file} = post
|
{file} = post
|
||||||
{isVideo} = file
|
{isVideo} = file
|
||||||
return if file.isExpanding or file.isExpanded
|
return if file.isExpanding or file.isExpanded
|
||||||
file.isHovered = true
|
|
||||||
error = ImageHover.error post
|
error = ImageHover.error post
|
||||||
if ImageCommon.cache?.dataset.fullID is post.fullID
|
if ImageCommon.cache?.dataset.fullID is post.fullID
|
||||||
el = ImageCommon.popCache()
|
el = ImageCommon.popCache()
|
||||||
$.on el, 'error', error
|
$.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
|
else
|
||||||
el = $.el (if isVideo then 'video' else 'img')
|
el = $.el (if isVideo then 'video' else 'img')
|
||||||
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
|
||||||
el.id = 'ihover'
|
el.id = 'ihover'
|
||||||
$.after Header.hover, el
|
$.after Header.hover, el
|
||||||
if isVideo
|
if isVideo
|
||||||
@ -63,7 +61,6 @@ ImageHover =
|
|||||||
el.removeAttribute 'id'
|
el.removeAttribute 'id'
|
||||||
el.removeAttribute 'style'
|
el.removeAttribute 'style'
|
||||||
ImageCommon.pushCache el
|
ImageCommon.pushCache el
|
||||||
$.queueTask -> delete file.isHovered
|
|
||||||
error: (post) -> ->
|
error: (post) -> ->
|
||||||
return if ImageCommon.decodeError @, post
|
return if ImageCommon.decodeError @, post
|
||||||
ImageCommon.error @, post, 3 * $.SECOND, (URL) =>
|
ImageCommon.error @, post, 3 * $.SECOND, (URL) =>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user