MCPcopy
hub / github.com/sveltejs/svelte / DevicePixelRatio

Class DevicePixelRatio

packages/svelte/src/reactivity/window/index.js:131–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129 * @since 5.11.0
130 */
131export const devicePixelRatio = /* @__PURE__ */ new (class DevicePixelRatio {
132 #dpr = source(BROWSER ? window.devicePixelRatio : undefined);
133
134 #update() {
135 const off = on(
136 window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),
137 'change',
138 () => {
139 set(this.#dpr, window.devicePixelRatio);
140
141 off();
142 this.#update();
143 }
144 );
145 }
146
147 constructor() {
148 if (BROWSER) {
149 this.#update();
150 }
151
152 if (DEV) {
153 tag(this.#dpr, 'window.devicePixelRatio');
154 }
155 }
156
157 get current() {
158 get(this.#dpr);
159 return BROWSER ? window.devicePixelRatio : undefined;
160 }
161})();

Callers

nothing calls this directly

Calls 1

sourceFunction · 0.90

Tested by

no test coverage detected