Skip to content

Commit

Permalink
fix language change animation bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
axherrm committed Jan 17, 2024
1 parent 5295f40 commit 36feeb8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
17 changes: 16 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,31 @@ export class AppComponent {

dataService: DataService;

alarmClockTimelines: gsap.core.Timeline[] = [];

constructor(dataService: DataService) {
this.dataService = dataService;
this.dataService.langChange.subscribe(() => this.onLangChange());
}

ngAfterViewInit(): void {
this.addLangButtonAnimation();
this.addProgressBarAnimation();
// @ts-ignore
for (let el of document.getElementsByClassName("alarm-clock-animated")) {
this.addAlarmClockAnimation(el);
}
this.addProgressBarAnimation();
}

onLangChange() {
this.alarmClockTimelines.forEach(tl => tl.kill());
this.alarmClockTimelines = [];

let objectsToAnimate = document.getElementsByClassName("alarm-clock-animated");
// @ts-ignore
for (let el of objectsToAnimate) {
this.addAlarmClockAnimation(el);
}
}

addProgressBarAnimation() {
Expand Down Expand Up @@ -134,6 +148,7 @@ export class AppComponent {
rotationX: "30deg",
transformPerspective: "1400px",
})
this.alarmClockTimelines.push(bottomHalfTl, upperHalfTl);
}

}
9 changes: 7 additions & 2 deletions src/app/data/data.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Injectable} from '@angular/core';
import {EventEmitter, Injectable} from '@angular/core';
import * as educationJson from '../../data/education.json';
import * as generalJson from '../../data/general.json';
import * as experienceJson from '../../data/experience.json';
Expand All @@ -22,6 +22,8 @@ export class DataService {
skillCategories: SkillCategory[];
skills: Skill[];

langChange: EventEmitter<void> = new EventEmitter<void>(true);

constructor() {
this.determineLanguage();
}
Expand Down Expand Up @@ -72,7 +74,10 @@ export class DataService {
this.languagesMenuItems.push({
id: langPack.id,
icon: `fi fis fi-${langPack.isoAlpha2} flag-icon${flagActive}`,
command: () => this.setLang(lang)
command: () => {
this.setLang(lang);
this.langChange.emit();
}
})
}

Expand Down

0 comments on commit 36feeb8

Please sign in to comment.