I work on a Social Media Page with Django/Python.
The
feed.html diplays the Posts of Users. It is paginated, but I have an Infinite script where it automatically displays the next page, without needing to click to the next page. Users can upload Videos and Images, if you hover over the videos, it gets played.
The script:
var videos = document.querySelectorAll('video');
for(var i=0; i<videos.length; i++)
videos[i].addEventListener('play', function(){pauseAll(this)}, true);
function pauseAll(elem){
for(var i=0; i<videos.length; i++){
if(videos[i] == elem) continue;
if(videos[i].played.length > 0 && !videos[i].paused){
videos[i].pause();
}
}
}
prevents multiple videos from getting played, so if you hover over a video and it plays, but you hover over another video, the video before stops playing. That works well.
The Script for my infinite scroll is as follows:
var infinite = new Waypoint.Infinite({
element: $('.infinite-container')[0],
offset: 'bottom-in-view',
onBeforePageLoad: function () {
$('.loading').show();
},
onAfterPageLoad: function ($items) {
$('.loading').hide();
}
});
But on the next Page, it doesn't apply, how do I fix that?
P.S.: Sorry for my bad English!
What I have tried:
I could not come up with a solution, so I tried nothing yet.