fix resizing issue on mobile

This commit is contained in:
2026-01-21 08:16:07 +01:00
parent 11b132756a
commit f4bffc353b

View File

@@ -1,4 +1,4 @@
import {afterNextRender, AfterViewInit, Component, ElementRef, NgZone, OnDestroy, ViewChild} from '@angular/core';
import {afterNextRender, Component, ElementRef, NgZone, OnDestroy, ViewChild} from '@angular/core';
import {Dot} from '../../models/dot';
@Component({
@@ -49,8 +49,17 @@ export class DotBackground implements OnDestroy {
private resize = () => {
const canvas = this.canvasRef.nativeElement;
const viewport = window.visualViewport;
if (viewport) {
// Modern browsers
canvas.width = Math.round(viewport.width * viewport.scale);
canvas.height = Math.round(viewport.height * viewport.scale);
} else {
// Fallback
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
// Clamp dots to new bounds
for (const dot of this.dots) {