Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added particles loaded event to angular component
- Loading branch information
1 parent
18a691a
commit 81400e8
Showing
1 changed file
with
9 additions
and
5 deletions.
There are no files selected for viewing
14 changes: 9 additions & 5 deletions
14
components/angular/projects/ng-particles/src/lib/ng-particles.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { AfterViewInit, Component, EventEmitter, Input, Output } from '@angular/core'; | ||
import { tsParticles } from 'tsparticles'; | ||
import { IParticlesParams } from './ng-particles.module'; | ||
import { Container } from "tsparticles/dist/Core/Container"; | ||
|
||
@Component({ | ||
selector: 'Particles', | ||
template: ` | ||
<div [id]="id"></div> `, | ||
<div [id]="id"></div>`, | ||
styles: [] | ||
}) | ||
export class NgParticlesComponent implements OnInit { | ||
export class NgParticlesComponent implements AfterViewInit { | ||
constructor() { | ||
} | ||
|
||
@Input() options: IParticlesParams; | ||
@Input() id: string; | ||
@Output() particlesLoaded: EventEmitter<Container> = new EventEmitter<Container>(); | ||
|
||
ngOnInit(): void { | ||
tsParticles.load(this.id, this.options); | ||
ngAfterViewInit(): void { | ||
tsParticles.load(this.id, this.options).then(container => { | ||
this.particlesLoaded.emit(container); | ||
}); | ||
} | ||
} |