비디오를 표시하는이 캔버스의 크기를 조정하는 데 문제가 있습니다. 크기를 조정 한 후에는 "이전"및 "이후"창 크기 사이에서 계속해서 서로 다른 크기로 움직입니다.캔버스에있는 비디오의 크기가 계속 조절됩니다.
나는 this 개의 게시물 아이디어를 시도했지만 Chrome을 조금 진정시킨 것처럼 보였지만 Firefox에는 아무런 영향을 미치지 않았습니다.
This other 게시물을 통해 아이디어를 얻었지만 여전히 해결하지 못했습니다. 그것은 어느 쪽이든 나는 (내가 보지 못하는) 루프에서 여러 번 resize를 호출하거나 캔버스의 컨텍스트가 최종 크기를 결정하는 방법을 모르는 것처럼 보입니다. 어떤 아이디어?
<!DOCTYPE html>
<html>
<head>
<title>overflow</title>
<style>
#c {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 100%;
height: 100%;
z-index: 1;
}
#hold {
position: fixed;
}
#v {
position: absolute;
height: auto;
width: 100%;
z-index: 0;
}
#see {
position: relative;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 2;
}
</style>
</head>
<body>
<canvas id=c></canvas>
<div id=hold>
<video id=v>
</video>
</div>
<canvas id=see></canvas>
<script>
window.onload = start;
function start() {
var v = document.getElementById('v');
var house = document.getElementById('hold');
var base = document.getElementById('c');
var canvas = base.getContext('2d');
var cover = document.getElementById('see');
var canvastwo = cover.getContext('2d');
v.src=("keyed.ogv")
v.load();
v.play();
resize();
function resize() {
var wth = (window.innerWidth * 0.65);
house.width = wth;
house.height = (wth * 9/16);
house.style.marginTop=((window.innerHeight/2) - (house.height/2) + "px");
house.style.marginLeft=((window.innerWidth/2) - (house.width/2) + "px");
cover.width = (wth/2);
cover.height = (house.height/2);
cover.style.marginTop=((window.innerHeight/2) - (cover.height/2) + "px");
cover.style.marginLeft=((window.innerWidth/2) - (cover.width/2) + "px");
var rw = cover.width;
var rh = cover.height;
canvastwo.clearRect(0, 0, rw, rh);
draw(v, canvastwo, rw, rh);
}
window.onresize = resize;
function draw(o,j,w,h) {
if(v.paused || v.ended) return false;
j.drawImage(o,0,0,w,h);
setTimeout(draw,20,o,j,w,h);
}
}
</script>
</body>
</html>
크기 조정 이벤트는 어떤 이유로, 여러 번 발생합니다. 함수를 명시 적으로 호출하고 창 크기 조정 수신 대기를 중지하더라도 지터가 여전히 발생합니다. 이것은 캔버스의 동작 일뿐입니다. 비디오를 표시하면 문제없이 하루 종일 크기를 조정할 수 있습니다. –