I\'m doing a website with the skrollr plugin and I\'m almost done with the pictures and scrolling itself, so I\'m trying to add the audio now, but I can\'t seem to make the
var playing = false;
var audioElm = $('#soundTour').get(0);
$(window).scroll(function() {
var pageScroll = $(window).scrollTop();
if(!playing && pageScroll > 500 && pageScroll < 3000){
audioElm.play();
playing = true;
}else if(pageScroll > 3000 || pageScroll < 500){
audioElm.pause();
playing = false;
}
});
You need to add some conditions. (I define the variables outside for performance matters, as jQuery scroll has really bad performance, that gets even worse on phones).
Pen: http://codepen.io/vandervals/pen/KpWzVJ