Are you an LLM? You can read better optimized documentation at /mobx-web-api/apis/viewport-info.md for this page in Markdown format
Viewport Info
ts
import { viewportInfo } from "mobx-web-api";Allows tracking visual viewport dimensions and scale.
What's inside
Uses Visual Viewport API under the hood.
Usage
ts
import { viewportInfo } from "mobx-web-api";
import { reaction } from "mobx";
reaction(
() => viewportInfo.height,
(height) => {
console.log(`visual viewport height: ${height}`);
}
);Properties
isSupported
true when window.visualViewport exists.
width / height
Visual viewport size.
offsetLeft / offsetTop
Offset of visual viewport relative to layout viewport.
pageLeft / pageTop
Coordinates of visual viewport relative to initial containing block.
scale
Current pinch-zoom scale factor.
isKeyboardLikeOverlay
Heuristic flag that becomes true when visual viewport is much smaller than layout viewport.
Notes
- If VisualViewport API is unavailable, falls back to
window.innerWidth/innerHeight. - Keyboard overlay detection is heuristic and may vary by browser.
