Skip to content

Commit

Permalink
Ensure that out-of-viewport videos aren't played.
Browse files Browse the repository at this point in the history
Fixes dhg#15.
  • Loading branch information
alecthomas committed Sep 13, 2015
1 parent 34b3242 commit 8a2706d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions javascripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,10 @@ $(document).ready(function() {
}

function playVisibleVideos() {
// $('video').each(function(){
// this.pause();
// });

if (!isTouchDevice) {
$('video:not(in-viewport)').each(function(){
this.pause();
})
$('video:in-viewport').each(function(){
this.play();
})
Expand Down Expand Up @@ -103,6 +102,8 @@ $(document).ready(function() {

throttledVideo = throttle(playVisibleVideos, 100)

$(window).load(throttledVideo);

$(window).scroll(function(){

// Load more JSON from scroll
Expand Down

0 comments on commit 8a2706d

Please sign in to comment.