diff --git a/src/General/Header.coffee b/src/General/Header.coffee index 541bf697f..ec293a3f4 100755 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -407,6 +407,7 @@ Header = bottom -= clientHeight - headRect.bottom + headRect.height bottom isNodeVisible: (node) -> + return false if d.hidden or !doc.contains node {height} = node.getBoundingClientRect() Header.getTopOf(node) + height >= 0 and Header.getBottomOf(node) + height >= 0 isHidden: -> diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index 3043dcace..8baebc148 100755 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -70,15 +70,15 @@ ImageExpand = playVideos: (e) -> g.posts.forEach (post) -> - return unless post.file and post.file.isVideo and post.file.isExpanded - video = post.file.fullImage - visible = !d.hidden and Header.isNodeVisible video - if visible and post.file.wasPlaying - delete post.file.wasPlaying - video.play() - else if !visible and !video.paused - post.file.wasPlaying = true - video.pause() + for post in [post, post.clones...] when post.file and post.file.isVideo and post.file.isExpanded + video = post.file.fullImage + visible = Header.isNodeVisible video + if visible and post.file.wasPlaying + delete post.file.wasPlaying + video.play() + else if !visible and !video.paused + post.file.wasPlaying = true + video.pause() return setFitness: -> @@ -216,11 +216,14 @@ ImageExpand = fullImage.controls = controls return fullImage.controls = false - $.asap (=> doc.contains fullImage), => - if !d.hidden and Header.isNodeVisible fullImage - fullImage.play() - else - post.file.wasPlaying = true + if post.isFetchedQuote + post.file.wasPlaying = true + else + $.asap (=> doc.contains fullImage), => + if !d.hidden and Header.isNodeVisible fullImage + fullImage.play() + else + post.file.wasPlaying = true if controls ImageCommon.addControls fullImage diff --git a/src/Images/ImageLoader.coffee b/src/Images/ImageLoader.coffee index 672ada0c6..6be528bfb 100755 --- a/src/Images/ImageLoader.coffee +++ b/src/Images/ImageLoader.coffee @@ -10,10 +10,10 @@ ImageLoader = if Conf['Replace WEBM'] and Conf['Autoplay'] $.on d, 'scroll visibilitychange', -> g.posts.forEach (post) -> - if post.file?.videoThumb + for post in [post, post.clones...] when post.file?.videoThumb {thumb} = post.file - visible = !d.hidden and Header.isNodeVisible thumb - if visible then thumb.play() else thumb.pause() + if Header.isNodeVisible thumb then thumb.play() else thumb.pause() + return return unless Conf['Image Prefetching']