move stuff from Image.completeExpand to Image.expand
This commit is contained in:
parent
09dee74ca5
commit
7bdd8a31e1
@ -129,19 +129,36 @@ 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, isVideo} = post.file
|
{file} = post
|
||||||
return if post.isHidden or post.file.isExpanding or post.file.isExpanded
|
{thumb, isVideo} = file
|
||||||
post.file.isExpanding = true
|
return if post.isHidden or file.isExpanding or file.isExpanded
|
||||||
|
|
||||||
$.addClass thumb, 'expanding'
|
$.addClass thumb, 'expanding'
|
||||||
el = post.file.fullImage or $.el (if isVideo then 'video' else 'img'), className: 'full-image'
|
file.isExpanding = true
|
||||||
|
|
||||||
|
el = file.fullImage or $.el (if isVideo then 'video' else 'img'), className: 'full-image'
|
||||||
$.on el, 'error', ImageExpand.error
|
$.on el, 'error', ImageExpand.error
|
||||||
if post.file.fullImage
|
if file.fullImage
|
||||||
# Expand already-loaded/ing picture.
|
# Expand already-loaded/ing picture.
|
||||||
TrashQueue.remove el
|
TrashQueue.remove el
|
||||||
else
|
else
|
||||||
el.src = src or post.file.URL
|
el.src = src or file.URL
|
||||||
$.after thumb, el
|
$.after thumb, el
|
||||||
post.file.fullImage = el
|
file.fullImage = el
|
||||||
|
|
||||||
|
if isVideo
|
||||||
|
# add contract link to file info
|
||||||
|
if Conf['Show Controls'] and !file.videoControls
|
||||||
|
file.videoControls = ImageExpand.videoControls.cloneNode true
|
||||||
|
$.add file.text, file.videoControls
|
||||||
|
|
||||||
|
# disable link to file so native controls can work
|
||||||
|
thumb.parentNode.removeAttribute 'href'
|
||||||
|
thumb.parentNode.removeAttribute 'target'
|
||||||
|
|
||||||
|
el.loop = true
|
||||||
|
ImageExpand.setupVideoCB post
|
||||||
|
|
||||||
$.asap (-> if isVideo then el.readyState >= el.HAVE_CURRENT_DATA else el.naturalHeight), ->
|
$.asap (-> if isVideo then el.readyState >= el.HAVE_CURRENT_DATA else el.naturalHeight), ->
|
||||||
if post.nodes.root.parentNode
|
if post.nodes.root.parentNode
|
||||||
{bottom} = post.nodes.root.getBoundingClientRect()
|
{bottom} = post.nodes.root.getBoundingClientRect()
|
||||||
@ -154,38 +171,26 @@ ImageExpand =
|
|||||||
{file} = post
|
{file} = post
|
||||||
return unless file.isExpanding # contracted before the image loaded
|
return unless file.isExpanding # contracted before the image loaded
|
||||||
|
|
||||||
$.rmClass file.thumb, 'expanding'
|
|
||||||
$.addClass post.nodes.root, 'expanded-image'
|
$.addClass post.nodes.root, 'expanded-image'
|
||||||
delete file.isExpanding
|
$.rmClass file.thumb, 'expanding'
|
||||||
file.isExpanded = true
|
file.isExpanded = true
|
||||||
|
delete file.isExpanding
|
||||||
|
|
||||||
if file.isVideo
|
{bottom, height} = file.fullImage.getBoundingClientRect()
|
||||||
# add contract link to file info
|
|
||||||
if Conf['Show Controls']
|
|
||||||
file.videoControls = ImageExpand.videoControls.cloneNode true
|
|
||||||
$.add file.text, file.videoControls
|
|
||||||
|
|
||||||
# disable link to file so native controls can work
|
|
||||||
file.thumb.parentNode.removeAttribute 'href'
|
|
||||||
file.thumb.parentNode.removeAttribute 'target'
|
|
||||||
|
|
||||||
video = file.fullImage
|
|
||||||
video.loop = true
|
|
||||||
ImageExpand.setupVideoCB post
|
|
||||||
ImageExpand.play post if Conf['Autoplay']
|
|
||||||
ImageCommon.addControls video if Conf['Show Controls']
|
|
||||||
|
|
||||||
# Scroll to keep our place in the thread when images are expanded above us.
|
# Scroll to keep our place in the thread when images are expanded above us.
|
||||||
if oldBottom? and oldBottom <= 0
|
if oldBottom? and oldBottom <= 0
|
||||||
window.scrollBy 0, post.nodes.root.getBoundingClientRect().bottom - oldBottom
|
window.scrollBy 0, bottom - oldBottom
|
||||||
return
|
|
||||||
|
|
||||||
# Scroll to display full image.
|
# Scroll to display full image.
|
||||||
imageBottom = Header.getBottomOf file.fullImage
|
imageBottom = Header.getBottomOf file.fullImage
|
||||||
{height} = file.fullImage.getBoundingClientRect()
|
|
||||||
if imageBottom + height >= 0 and imageBottom < 0
|
if imageBottom + height >= 0 and imageBottom < 0
|
||||||
window.scrollBy 0, Math.min(-imageBottom, Header.getTopOf file.fullImage)
|
window.scrollBy 0, Math.min(-imageBottom, Header.getTopOf file.fullImage)
|
||||||
|
|
||||||
|
if file.isVideo
|
||||||
|
ImageExpand.play post if Conf['Autoplay']
|
||||||
|
ImageCommon.addControls file.fullImage if Conf['Show Controls']
|
||||||
|
|
||||||
play: (post) ->
|
play: (post) ->
|
||||||
if !d.hidden and Header.isNodeVisible post.file.fullImage
|
if !d.hidden and Header.isNodeVisible post.file.fullImage
|
||||||
post.file.fullImage.play()
|
post.file.fullImage.play()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user