Don't add the 'expanding' class when unecessary.
This commit is contained in:
parent
40d8d06266
commit
7f1abad58b
@ -15,16 +15,12 @@ ImageExpand =
|
|||||||
node: ->
|
node: ->
|
||||||
return unless @file and (@file.isImage or @file.isVideo)
|
return unless @file and (@file.isImage or @file.isVideo)
|
||||||
$.on @file.thumb.parentNode, 'click', ImageExpand.cb.toggle
|
$.on @file.thumb.parentNode, 'click', ImageExpand.cb.toggle
|
||||||
if @isClone
|
if @isClone and @file.isImage and @file.isExpanding
|
||||||
if @file.isImage and $.hasClass @file.thumb, 'expanding'
|
|
||||||
# If we clone a post where the image is still loading,
|
# If we clone a post where the image is still loading,
|
||||||
# make it loading in the clone too.
|
# make it loading in the clone too.
|
||||||
ImageExpand.contract @
|
ImageExpand.contract @
|
||||||
ImageExpand.expand @
|
ImageExpand.expand @
|
||||||
return
|
return
|
||||||
if @file.isVideo and @file.isExpanded
|
|
||||||
@file.fullImage.play()
|
|
||||||
return
|
|
||||||
if ImageExpand.on and !@isHidden and (Conf['Expand spoilers'] or !@file.isSpoiler)
|
if ImageExpand.on and !@isHidden and (Conf['Expand spoilers'] or !@file.isSpoiler)
|
||||||
ImageExpand.expand @
|
ImageExpand.expand @
|
||||||
cb:
|
cb:
|
||||||
@ -57,7 +53,7 @@ ImageExpand =
|
|||||||
|
|
||||||
toggle: (post) ->
|
toggle: (post) ->
|
||||||
{thumb} = post.file
|
{thumb} = post.file
|
||||||
unless post.file.isExpanded or $.hasClass thumb, 'expanding'
|
unless post.file.isExpanded or post.file.isExpanding
|
||||||
ImageExpand.expand post
|
ImageExpand.expand post
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -79,9 +75,7 @@ ImageExpand =
|
|||||||
|
|
||||||
expand: (post, src) ->
|
expand: (post, src) ->
|
||||||
# Do not expand images of hidden/filtered replies, or already expanded pictures.
|
# Do not expand images of hidden/filtered replies, or already expanded pictures.
|
||||||
{thumb} = post.file
|
return if post.file.isExpanding or post.file.isExpanded
|
||||||
return if post.file.isExpanded or $.hasClass thumb, 'expanding'
|
|
||||||
$.addClass thumb, 'expanding'
|
|
||||||
if post.file.fullImage
|
if post.file.fullImage
|
||||||
# Expand already-loaded/ing picture.
|
# Expand already-loaded/ing picture.
|
||||||
ImageExpand.waitExpand post
|
ImageExpand.waitExpand post
|
||||||
@ -97,12 +91,16 @@ ImageExpand =
|
|||||||
loop: true
|
loop: true
|
||||||
$.on file, 'error', ImageExpand.error
|
$.on file, 'error', ImageExpand.error
|
||||||
ImageExpand.waitExpand post
|
ImageExpand.waitExpand post
|
||||||
$.after thumb, file
|
$.after post.file.thumb, file
|
||||||
|
|
||||||
waitExpand: (post) ->
|
waitExpand: (post) ->
|
||||||
|
post.file.isExpanding = true
|
||||||
if post.file.isReady
|
if post.file.isReady
|
||||||
ImageExpand.completeExpand post
|
ImageExpand.completeExpand post
|
||||||
else if post.file.isImage
|
return
|
||||||
|
|
||||||
|
$.addClass post.file.thumb, 'expanding'
|
||||||
|
if post.file.isImage
|
||||||
$.asap (-> post.file.fullImage.naturalHeight), ->
|
$.asap (-> post.file.fullImage.naturalHeight), ->
|
||||||
post.file.isReady = true
|
post.file.isReady = true
|
||||||
ImageExpand.completeExpand post
|
ImageExpand.completeExpand post
|
||||||
@ -115,7 +113,8 @@ ImageExpand =
|
|||||||
|
|
||||||
completeExpand: (post) ->
|
completeExpand: (post) ->
|
||||||
{thumb} = post.file
|
{thumb} = post.file
|
||||||
return unless $.hasClass thumb, 'expanding' # contracted before the image loaded
|
return unless post.file.isExpanding # contracted before the image loaded
|
||||||
|
delete post.file.isExpanding
|
||||||
post.file.isExpanded = true
|
post.file.isExpanded = true
|
||||||
post.file.fullImage.play() if post.file.isVideo
|
post.file.fullImage.play() if post.file.isVideo
|
||||||
unless post.nodes.root.parentNode
|
unless post.nodes.root.parentNode
|
||||||
@ -139,7 +138,7 @@ ImageExpand =
|
|||||||
# Images can error:
|
# Images can error:
|
||||||
# - before the image started loading.
|
# - before the image started loading.
|
||||||
# - after the image started loading.
|
# - after the image started loading.
|
||||||
unless $.hasClass(post.file.thumb, 'expanding') or $.hasClass post.nodes.root, 'expanded-image'
|
unless post.file.isExpanding or post.file.isExpanded
|
||||||
# Don't try to re-expend if it was already contracted.
|
# Don't try to re-expend if it was already contracted.
|
||||||
return
|
return
|
||||||
ImageExpand.contract post
|
ImageExpand.contract post
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user