Skip to content

Instantly share code, notes, and snippets.

@pfgithub
Created October 5, 2021 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfgithub/11c8a43daa8a6964ac256b39c607b156 to your computer and use it in GitHub Desktop.
Save pfgithub/11c8a43daa8a6964ac256b39c607b156 to your computer and use it in GitHub Desktop.
visualviewport
{
if(window.__vvviewer) window.__vvviewer.remove();
window.__vvviewer = document.createElement("div");
__vvviewer.setAttribute("style", "position:fixed;left:0;right:0;width:100%;background-color:red;height:4px;z-index:1000000");
document.body.appendChild(__vvviewer);
function update() {
__vvviewer.style.top = visualViewport.offsetTop + "px";
//__vvviewer.style.transform = "scaleY("+(1 / visualViewport.scale)+")"
}
visualViewport.onresize = () => {
update();
};
visualViewport.onscroll = () => {
update();
};
update();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment