Created
December 17, 2025 17:56
-
-
Save greggman/22b30befb983994d42758f30c1f485f3 to your computer and use it in GitHub Desktop.
Check window.visualViewport.scale
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :root { color-scheme: light dark; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <pre></pre> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"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