Documentation / @finchart/dom / observeDevicePixelRatio
Function: observeDevicePixelRatio()
observeDevicePixelRatio(
element):ResolutionObserver
Defined in: dom/src/observe-resolution.ts:20
The browser implementation that reports devicePixelRatio changes — the element is pre-bound by browserDeps: observeResolution: observeDevicePixelRatio(container).
Browsers don't announce a resolution change — not even resize fires. Instead, building a media query pinned to the current ratio gets one change event the moment that condition breaks. A fired query is tied to the old ratio and can't be reused, so a resubscribe loop rebuilds the query at the new ratio every time.
The element is taken for the same reason as observeElementSize — a chart inside an iframe needs to watch its own document's window. In an environment without matchMedia (SSR, some of jsdom), this does nothing and doesn't throw — there's just nothing to observe, not a broken state.
Parameters
element
HTMLElement
Returns
ResolutionObserver