[Added] Animations, Intro, Projects, Spinning links

This commit is contained in:
Ninjaws
2024-11-22 02:56:26 +01:00
parent 87ca17c1ba
commit 007c3dd588
26 changed files with 366 additions and 244 deletions
+38 -2
View File
@@ -1,4 +1,4 @@
import { Component } from '@angular/core';
import { AfterViewInit, Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { HeaderComponent } from './header/header.component';
import { AboutComponent } from './about/about.component';
@@ -12,6 +12,42 @@ import { SkillsComponent } from './skills/skills.component';
templateUrl: './app.component.html',
styleUrl: './app.component.scss'
})
export class AppComponent {
export class AppComponent implements AfterViewInit {
title = 'portfolio';
ngAfterViewInit(): void {
this.observeProjects();
}
/** Watches for elements tagged with a fade-in animation when the user scrolls by them */
observeProjects() {
let projectItems: any[] = [];
const ups = document.querySelectorAll('.fade-in-up');
const lefts = document.querySelectorAll('.fade-in-left');
projectItems = projectItems.concat(ups);
projectItems = [...ups, ...lefts];
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
if (entry.target.classList.contains("fade-in-up")){
entry.target.classList.add('fade-in-up-ani');
entry.target.classList.remove('fade-in-up'); // Tp get rid of the opacity 0, conflicts with the scale animation
}
if (entry.target.classList.contains("fade-in-left")){
entry.target.classList.add('fade-in-left-ani');
entry.target.classList.remove('fade-in-left'); // Tp get rid of the opacity 0, conflicts with the scale animation
}
observer.unobserve(entry.target);
}
});
}, {
threshold: 0.2,
});
projectItems.forEach(item => {
observer.observe(item);
});
}
}