diff --git a/src/app/shared/components/particles-background/particles-background.component.ts b/src/app/shared/components/particles-background/particles-background.component.ts index 3f2974c..8d50f59 100644 --- a/src/app/shared/components/particles-background/particles-background.component.ts +++ b/src/app/shared/components/particles-background/particles-background.component.ts @@ -1,4 +1,4 @@ -import {AfterViewInit, Component, ElementRef, HostListener, NgZone, OnDestroy, ViewChild} from '@angular/core'; +import {AfterViewInit, Component, ElementRef, HostListener, inject, NgZone, OnDestroy, ViewChild} from '@angular/core'; @Component({ selector: 'app-particles-background', @@ -9,6 +9,8 @@ import {AfterViewInit, Component, ElementRef, HostListener, NgZone, OnDestroy, V export class ParticleBackgroundComponent implements AfterViewInit, OnDestroy { @ViewChild('canvas', { static: true }) canvasRef!: ElementRef; + private readonly ngZone = inject(NgZone); + private ctx!: CanvasRenderingContext2D; private particles: any[] = []; private animationFrameId: number = 0; @@ -18,8 +20,6 @@ export class ParticleBackgroundComponent implements AfterViewInit, OnDestroy { private readonly maxDistance = 150; private readonly particleSpeed = 0.8; - constructor(private readonly ngZone: NgZone) {} - ngAfterViewInit(): void { const canvas = this.canvasRef.nativeElement; this.ctx = canvas.getContext('2d')!;