Update particles-background.component.ts
This commit is contained in:
@@ -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<HTMLCanvasElement>;
|
||||
|
||||
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')!;
|
||||
|
||||
Reference in New Issue
Block a user