fix: performance and style

This commit is contained in:
2026-05-14 15:57:12 +02:00
parent d8d1528fa9
commit 24862a33d0
4 changed files with 95 additions and 17 deletions
+2 -2
View File
@@ -442,7 +442,7 @@ describe('HomeComponent', (): void => {
expect(comp.shouldEnableScrollEffects()).toBeTrue();
});
it('should disable scroll effects on coarse touch pointers', (): void => {
it('should keep scroll effects enabled on coarse touch pointers when motion is allowed', (): void => {
spyOn(window, 'matchMedia').and.callFake(
(query: string): MediaQueryList =>
({
@@ -450,7 +450,7 @@ describe('HomeComponent', (): void => {
}) as MediaQueryList,
);
expect(comp.shouldEnableScrollEffects()).toBeFalse();
expect(comp.shouldEnableScrollEffects()).toBeTrue();
});
it('should disable scroll effects when reduced motion is requested', (): void => {
+4 -4
View File
@@ -233,22 +233,21 @@ export class HomeComponent implements OnInit, AfterViewInit, OnDestroy {
const prefersReducedMotion: boolean = window.matchMedia(
'(prefers-reduced-motion: reduce)',
).matches;
const usesTouchScrolling: boolean = window.matchMedia(
'(hover: none) and (pointer: coarse)',
).matches;
return !prefersReducedMotion && !usesTouchScrolling;
return !prefersReducedMotion;
}
private initNameGradientScrollAnimation(): void {
if (!this.shouldEnableScrollEffects()) return;
window.addEventListener('scroll', this.scheduleNameGradientUpdate, { passive: true });
window.addEventListener('resize', this.scheduleNameGradientUpdate, { passive: true });
this.scheduleNameGradientUpdate();
}
private initProjectEntryRevealObserver(): void {
if (!this.shouldEnableScrollEffects()) return;
window.addEventListener('scroll', this.scheduleProjectEntryRevealUpdate, { passive: true });
window.addEventListener('resize', this.scheduleProjectEntryRevealUpdate, { passive: true });
this.scheduleProjectEntryRevealUpdate();
}
private destroyProjectEntryRevealObserver(): void {
if (typeof window === 'undefined' || typeof document === 'undefined') return;
@@ -270,6 +269,7 @@ export class HomeComponent implements OnInit, AfterViewInit, OnDestroy {
window.addEventListener('resize', this.scheduleAboutSectionScrollAnimationUpdate, {
passive: true,
});
this.scheduleAboutSectionScrollAnimationUpdate();
}
private destroyAboutSectionScrollAnimation(): void {
if (typeof window === 'undefined' || typeof document === 'undefined') return;