1
Canvas가 높이를 어떻게하면 내 페이지가 어떻게 보이는지 보여주는 데모입니다. 아래로 스크롤 할 때도이 캔버스를 표시해야합니다. 지금은 첫 번째 창보기 높이를 계산합니다. demo : 어떤 제안이 많이 주시면 감사하겠습니다스크롤 할 때 캔버스 높이 재 계산
(function() {
var canvas = document.getElementById('canvas'),
context = canvas.getContext('2d');
// resize the canvas to fill browser window dynamically
window.addEventListener('resize', resizeCanvas, false);
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
//canvas is showing on my demo in Fiddle
/**
* drawings need to be inside this function otherwise they will be reset when
* you resize the browser window and the canvas goes will be cleared.
*/
drawStuff();
}
resizeCanvas();
function drawStuff() {
// do your drawing stuff here
}
})();
.
난 당신이 원하는 정확한 기능 모르겠지만,''위치를 사용하지 않는 : 고정은,''에 관계없이 스크롤의 뷰포트에서 캔버스를 유지합니다. –
감사합니다. 이것은 간단한 수정입니다 !!! 고마워. – user2505665
도움이 된 것을 기쁘게 생각합니다. 답변의 "공식"버전을 올렸습니다 ^^ –