fix pause off screen for clones

This commit is contained in:
ccd0 2014-09-07 14:39:38 -07:00
parent 6b8e23d045
commit 656685a9be
3 changed files with 21 additions and 17 deletions

View File

@ -407,6 +407,7 @@ Header =
bottom -= clientHeight - headRect.bottom + headRect.height bottom -= clientHeight - headRect.bottom + headRect.height
bottom bottom
isNodeVisible: (node) -> isNodeVisible: (node) ->
return false if d.hidden or !doc.contains node
{height} = node.getBoundingClientRect() {height} = node.getBoundingClientRect()
Header.getTopOf(node) + height >= 0 and Header.getBottomOf(node) + height >= 0 Header.getTopOf(node) + height >= 0 and Header.getBottomOf(node) + height >= 0
isHidden: -> isHidden: ->

View File

@ -70,15 +70,15 @@ ImageExpand =
playVideos: (e) -> playVideos: (e) ->
g.posts.forEach (post) -> g.posts.forEach (post) ->
return unless post.file and post.file.isVideo and post.file.isExpanded for post in [post, post.clones...] when post.file and post.file.isVideo and post.file.isExpanded
video = post.file.fullImage video = post.file.fullImage
visible = !d.hidden and Header.isNodeVisible video visible = Header.isNodeVisible video
if visible and post.file.wasPlaying if visible and post.file.wasPlaying
delete post.file.wasPlaying delete post.file.wasPlaying
video.play() video.play()
else if !visible and !video.paused else if !visible and !video.paused
post.file.wasPlaying = true post.file.wasPlaying = true
video.pause() video.pause()
return return
setFitness: -> setFitness: ->
@ -216,11 +216,14 @@ ImageExpand =
fullImage.controls = controls fullImage.controls = controls
return return
fullImage.controls = false fullImage.controls = false
$.asap (=> doc.contains fullImage), => if post.isFetchedQuote
if !d.hidden and Header.isNodeVisible fullImage post.file.wasPlaying = true
fullImage.play() else
else $.asap (=> doc.contains fullImage), =>
post.file.wasPlaying = true if !d.hidden and Header.isNodeVisible fullImage
fullImage.play()
else
post.file.wasPlaying = true
if controls if controls
ImageCommon.addControls fullImage ImageCommon.addControls fullImage

View File

@ -10,10 +10,10 @@ ImageLoader =
if Conf['Replace WEBM'] and Conf['Autoplay'] if Conf['Replace WEBM'] and Conf['Autoplay']
$.on d, 'scroll visibilitychange', -> $.on d, 'scroll visibilitychange', ->
g.posts.forEach (post) -> g.posts.forEach (post) ->
if post.file?.videoThumb for post in [post, post.clones...] when post.file?.videoThumb
{thumb} = post.file {thumb} = post.file
visible = !d.hidden and Header.isNodeVisible thumb if Header.isNodeVisible thumb then thumb.play() else thumb.pause()
if visible then thumb.play() else thumb.pause() return
return unless Conf['Image Prefetching'] return unless Conf['Image Prefetching']