I'm about to make a website that I want to have a video background that advances only on page scrolling. I had found a solution at the start of the year but no matter how much I search or keyword searches for it again and failed miserably.
I remember it involved creation in After Effects and saving each frame as jpg, and how to code it in html5/css/js.
Any help would be gratefully received.
making a div at top as bound element to check the distance when scrolling.
inside function
scrollVideoi am checking if the video has played before.using
getBoundingClientRect().top:which returns value of a DOMRect object which is the smallest rectangle which contains the entire element, including its padding and border-width.Read More About it.getting
percentScrolledwith(window.scrollY - distanceFromTop)/(bound.scrollHeight - window.innerHeight). it may return a float value i.e. decimals. that's why i am performing math.min & math.max on it. gettingcurrenTimewithvideo.duration * percentScrolled& requesting animation on it.NOTE* video should be in
webmformat. i have'nt tested it in any other format.Actual Video Link