Skip to content

Instantly share code, notes, and snippets.

@greggman
Created December 17, 2025 17:56
Show Gist options
  • Select an option

  • Save greggman/22b30befb983994d42758f30c1f485f3 to your computer and use it in GitHub Desktop.

Select an option

Save greggman/22b30befb983994d42758f30c1f485f3 to your computer and use it in GitHub Desktop.
Check window.visualViewport.scale
:root { color-scheme: light dark; }
const elem = document.querySelector('pre');
let frameCount = 0;
function update() {
elem.textContent = `\
frameCount: ${frameCount++}
scale: ${window.visualViewport.scale}`;
requestAnimationFrame(update);
}
update();
window.addEventListener('resize', () => console.log('resize:', frameCount));
{"name":"Check window.visualViewport.scale","settings":{},"filenames":["index.html","index.css","index.js"]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment