Skip to content

Commit

Permalink
feat: added particles loaded event to angular component
Browse files Browse the repository at this point in the history
  • Loading branch information
matteobruni committed Aug 20, 2020
1 parent 18a691a commit 81400e8
Showing 1 changed file with 9 additions and 5 deletions.
@@ -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);
});
}
}

0 comments on commit 81400e8

Please sign in to comment.