fix resizing issue on mobile
This commit is contained in:
@@ -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';
|
import {Dot} from '../../models/dot';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -49,8 +49,17 @@ export class DotBackground implements OnDestroy {
|
|||||||
|
|
||||||
private resize = () => {
|
private resize = () => {
|
||||||
const canvas = this.canvasRef.nativeElement;
|
const canvas = this.canvasRef.nativeElement;
|
||||||
canvas.width = window.innerWidth;
|
const viewport = window.visualViewport;
|
||||||
canvas.height = window.innerHeight;
|
|
||||||
|
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
|
// Clamp dots to new bounds
|
||||||
for (const dot of this.dots) {
|
for (const dot of this.dots) {
|
||||||
|
|||||||
Reference in New Issue
Block a user