@gravity-ui/graph
Version:
Modern graph editor component
16 lines (15 loc) • 746 B
TypeScript
/**
* Observes devicePixelRatio changes (e.g. when a window is moved between monitors
* with different scaling). Calls `fn` whenever the DPR changes.
*
* Uses matchMedia with a resolution query tied to the current DPR value.
* When the DPR changes the query no longer matches, so we re-subscribe
* with the updated value — this is why `once: true` is used.
*
* The callback is deferred to the next animation frame to avoid a race condition
* where the `change` event fires before the browser has updated `devicePixelRatio`.
*
* @param fn - Callback receiving the current devicePixelRatio
* @returns Unsubscribe function that stops observing DPR changes
*/
export declare function observeDPR(fn: (dpr: number) => void): () => void;