Skip to content

Commit eb40edf

Browse files
committed
fix(website): handle devicePixelRatio change
1 parent 39ec9f1 commit eb40edf

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

apps/website/components/EffectLayer.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ export function EffectLayer({ children, className }: EffectLayerProps) {
243243
function update(time: number) {
244244
if (!isActive.current) return;
245245
uniforms.uTime.value = time * 0.001;
246+
renderer.dpr = window.devicePixelRatio;
246247
renderer.render({ scene: mesh });
247248
rRaf.current = requestAnimationFrame(update);
248249
}
@@ -254,13 +255,11 @@ export function EffectLayer({ children, className }: EffectLayerProps) {
254255
renderer.render({ scene: mesh });
255256
}
256257

257-
const ro = new ResizeObserver((entries) => {
258-
if (!isActive.current) return;
259-
if (entries.length == null) return;
260-
requestAnimationFrame(() => {
261-
resize(root.getBoundingClientRect());
262-
});
263-
});
258+
function handleResize() {
259+
resize(root.getBoundingClientRect());
260+
}
261+
262+
const ro = new ResizeObserver(handleResize);
264263

265264
ro.observe(root);
266265
rRaf.current = requestAnimationFrame(update);

0 commit comments

Comments
 (0)