I've found a really awesome slider on a website (https://antoni.de)
The slider has videos set as backgrounds and the transition effect makes the video break into pieces (bars, varying in width, depending on the scrollpos)
How could I achieve a relatively close version of this?
Here's my current code:
HTML + jQuery:
<div id="slider">
<canvas id="c" width='1920px' height='1080px'></canvas>
<video id="v" preload="auto" autoplay="" loop="" muted="">
<source src="common/vid/stage_loop.mp4">
</video>
</div>
<script>
// Copy video to canvas
document.addEventListener('DOMContentLoaded', function(){
var v = document.getElementById('v');
var canvas = document.getElementById('c');
var context = canvas.getContext('2d');
v.addEventListener('play', function(){
draw(this,context,canvas.width,canvas.height);
},false);
},false);
function draw(v,c,w,h) {
if(v.paused || v.ended) return false;
c.drawImage(v,0,0,w,h);
setTimeout(draw,20,v,c,w,h);
}
</script>
Css:
#slider {
display: block;
width: 100%;
height: 100vh;
background-color: black;
overflow: hidden;
position: relative;
}
#slider canvas {
position: absolute;
top: 50%;
left: 50%;
z-index: 1;
min-width: 1920px;
min-height: 1080px;
width: auto;
height: auto;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
#slider video {
position: absolute;
width: 20px;
height: 20px;
opacity: 0;
}
What could I do?:/
I've found nothing related online, I'm a beginner using html canvases