javascript - Onscroll video has to play once -
using scrolltop divide scroll 5 section using if condition.in 2nd section gave video scrolltop value 600 700px.the video playing many times within position if scroll again.but want video has play once if number of times within value.
var scrolld=window.scrolltop(); if(scrolld >=600) { ///i gave image here } elseif((scrolld >600) & (scrolld <=700)){ //video } //rest 3 elseif contain images
check link: http://projects.lollypop.biz/auluxa/lighting.html
if scrolled using mouse working fine.but if scrolled using keyup , keydown(keyboard) video playing many times.
please take @ code. think mean, since have on website aswel, question not clear. can atleast share ur code?
$('#vid').on('ended', function(){this.playedthrough = true;}); $(window).scroll(function(){ var myvideo = document.getelementbyid("vid"); if($(window).scrolltop() > 300 && $(window).scrolltop() < 975){ // if didn't reached end yet if(!myvideo.playedthrough) myvideo.play(); }else{ myvideo.pause(); } })
Comments
Post a Comment