import {AfterViewInit, Component, Inject, OnDestroy, OnInit, PLATFORM_ID} from '@angular/core'; import {VantaBackgroundService} from '../shared/services/vanta-background.service'; import {DeviceDetectorService} from '../shared/services/device-detector.service'; import {isPlatformBrowser, NgStyle} from '@angular/common'; import {Title} from '@angular/platform-browser'; import {AudioPlayerComponent} from '../shared/audio-player/audio-player.component'; import {TranslatePipe} from '@ngx-translate/core'; @Component({ selector: 'app-portfolio', imports: [ NgStyle, AudioPlayerComponent, TranslatePipe ], templateUrl: './portfolio.component.html', styleUrl: './portfolio.component.css' }) export class PortfolioComponent implements OnInit, OnDestroy, AfterViewInit { private readonly elementId = 'vanta-portfolio-bg'; isMobile: boolean = false; constructor( private vantaService: VantaBackgroundService, private deviceService: DeviceDetectorService, private titleService: Title, @Inject(PLATFORM_ID) private platformId: Object ) {} ngOnInit() { this.titleService.setTitle('Portfolio | itzMiney'); this.isMobile = this.deviceService.isMobile; if (isPlatformBrowser(this.platformId)) { window.addEventListener('resize', this.onResize.bind(this)); } } ngAfterViewInit() { this.vantaService.initVanta(this.elementId, { color: 0x514f80, backgroundColor: 0x291c3c }); } ngOnDestroy() { this.vantaService.destroyVanta(this.elementId); if (isPlatformBrowser(this.platformId)) { window.removeEventListener('resize', this.onResize); } } onResize() { // Update the minHeight and minWidth when the window is resized this.vantaService.resizeVanta(this.elementId); } }