-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Now it uses document.documentElement.clientHeigh
, however it doesn't change on show/hide status bar. In the original article they use window.innerHeight
, next code works for me:
var customViewportCorrectionVariable = 'vh';
function setViewportProperty(doc) {
var prevClientHeight;
var customVar = '--' + ( customViewportCorrectionVariable || 'vh' );
function handleResize() {
var clientHeight = window.innerHeight;
if (clientHeight === prevClientHeight) return;
requestAnimationFrame(function updateViewportHeight(){
doc.style.setProperty(customVar, (clientHeight * 0.01) + 'px');
prevClientHeight = clientHeight;
});
}
handleResize();
return handleResize;
}
window.addEventListener('resize', setViewportProperty(document.documentElement));
wallslide, finethanks, GeKorm, snackVal and LynXu-0
Metadata
Metadata
Assignees
Labels
No labels