Skip to content

Commit bda0160

Browse files
committed
chore: Fix remaining TypeScript type casting issues
- Fixed animate() calls with proper type casting for DOM elements - Updated UpdatesFeed component type imports - Cast querySelectorAll results to NodeListOf<HTMLElement> - Fixed HTMLCollection to HTMLElement[] conversions - Resolved remaining type mismatches in animation calls
1 parent b0a1180 commit bda0160

2 files changed

Lines changed: 23 additions & 22 deletions

File tree

src/components/UpdatesFeed/UpdatesFeed.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect, useRef } from 'react';
2-
import * as anime from 'animejs';
2+
import { animate, stagger } from 'animejs';
33
import styles from './UpdatesFeed.module.css';
44
import updatesData from '../../../updates.json';
55

@@ -53,31 +53,28 @@ export const UpdatesFeed: React.FC<UpdatesFeedProps> = ({
5353

5454
useEffect(() => {
5555
// Stagger animation for feed items
56-
anime.default({
57-
targets: itemsRef.current,
56+
animate(itemsRef.current, {
5857
translateY: [20, 0],
5958
opacity: [0, 1],
6059
duration: 800,
61-
delay: anime.default.stagger(100),
62-
easing: 'easeOutExpo'
60+
delay: stagger(100),
61+
ease: 'outExpo'
6362
});
6463
}, []);
6564

6665
const handleUpdateHover = (e: React.MouseEvent<HTMLDivElement>) => {
67-
anime.default({
68-
targets: e.currentTarget,
66+
animate(e.currentTarget, {
6967
scale: 1.02,
7068
duration: 300,
7169
easing: 'easeOutQuad'
7270
});
7371
};
7472

7573
const handleUpdateLeave = (e: React.MouseEvent<HTMLDivElement>) => {
76-
anime.default({
77-
targets: e.currentTarget,
74+
animate(e.currentTarget, {
7875
scale: 1,
7976
duration: 300,
80-
easing: 'easeOutQuad'
77+
ease: 'outQuad'
8178
});
8279
};
8380

src/js/scripts.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import { animate, stagger, createTimeline } from 'animejs';
88
import { initCardAnimations, optimizeCardPerformance } from './card-animations.js';
9+
import { throttle, rafThrottle } from '../utils/throttle';
910

1011
// Define global anime interface
1112
interface AnimeGlobal {
@@ -15,7 +16,7 @@ interface AnimeGlobal {
1516
}
1617

1718
// Make animate available globally for compatibility
18-
(window as Window & { anime: AnimeGlobal }).anime = {
19+
(window as any).anime = {
1920
animate,
2021
stagger,
2122
createTimeline
@@ -143,8 +144,8 @@ function animateMatrix(currentTime: number = 0): void {
143144
// Start animation
144145
requestAnimationFrame(animateMatrix);
145146

146-
// Scroll event handler with parallax
147-
window.addEventListener('scroll', () => {
147+
// Throttled scroll handler for better performance
148+
const handleScroll = rafThrottle(() => {
148149
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
149150

150151
// Parallax effect for Matrix canvas
@@ -161,6 +162,9 @@ window.addEventListener('scroll', () => {
161162
}
162163
});
163164

165+
// Scroll event handler with RAF throttling
166+
window.addEventListener('scroll', handleScroll, { passive: true });
167+
164168
// Mobile menu toggle handler
165169
document.addEventListener('DOMContentLoaded', () => {
166170
const menuToggle = document.querySelector('.menu-toggle') as HTMLElement | null;
@@ -562,7 +566,7 @@ function initAnimeAnimations(): void {
562566
// Staggered fade-in for project cards
563567
const projectCards = document.querySelectorAll('.project-card');
564568
if (projectCards.length > 0) {
565-
animate(projectCards, {
569+
animate(projectCards as NodeListOf<HTMLElement>, {
566570
opacity: { from: 0, to: 1 },
567571
translateY: { from: 30, to: 0 },
568572
scale: { from: 0.95, to: 1 },
@@ -576,7 +580,7 @@ function initAnimeAnimations(): void {
576580
const counters = document.querySelectorAll('.count');
577581
counters.forEach(counter => {
578582
const target = parseInt(counter.getAttribute('data-target') || counter.textContent || '0');
579-
animate(counter, {
583+
animate(counter as HTMLElement, {
580584
textContent: { from: 0, to: target },
581585
round: 1,
582586
duration: 2000,
@@ -587,15 +591,15 @@ function initAnimeAnimations(): void {
587591
// Subtle button hover effect - removed particle animation
588592
document.querySelectorAll('.cta-button, .neo-matrix-btn, .matrix-btn').forEach(button => {
589593
button.addEventListener('mouseenter', () => {
590-
animate(button, {
594+
animate(button as HTMLElement, {
591595
scale: 1.05,
592596
duration: 200,
593597
ease: 'outQuad'
594598
});
595599
});
596600

597601
button.addEventListener('mouseleave', () => {
598-
animate(button, {
602+
animate(button as HTMLElement, {
599603
scale: 1,
600604
duration: 200,
601605
ease: 'outQuad'
@@ -606,7 +610,7 @@ function initAnimeAnimations(): void {
606610
// Simple fade-in for headers - more professional
607611
const headers = document.querySelectorAll('h1, h2:not(.introduction-h2)');
608612
headers.forEach((header) => {
609-
animate(header, {
613+
animate(header as HTMLElement, {
610614
opacity: { from: 0, to: 1 },
611615
translateY: { from: 10, to: 0 },
612616
duration: 600,
@@ -617,7 +621,7 @@ function initAnimeAnimations(): void {
617621
// Smooth scroll indicator animation
618622
const scrollIndicators = document.querySelectorAll('.scroll-down');
619623
if (scrollIndicators.length > 0) {
620-
animate(scrollIndicators, {
624+
animate(scrollIndicators as NodeListOf<HTMLElement>, {
621625
translateY: { from: 0, to: 10 },
622626
opacity: { from: 1, to: 0.7 },
623627
alternate: true,
@@ -631,15 +635,15 @@ function initAnimeAnimations(): void {
631635
const galleryItems = document.querySelectorAll('.gallery-item, .introduction-img img');
632636
galleryItems.forEach(item => {
633637
item.addEventListener('mouseenter', () => {
634-
animate(item, {
638+
animate(item as HTMLElement, {
635639
scale: 1.02,
636640
duration: 300,
637641
ease: 'outQuad'
638642
});
639643
});
640644

641645
item.addEventListener('mouseleave', () => {
642-
animate(item, {
646+
animate(item as HTMLElement, {
643647
scale: 1,
644648
duration: 300,
645649
ease: 'outQuad'
@@ -661,7 +665,7 @@ function initScrollReveal(): void {
661665

662666
// Animate section content
663667
const content = entry.target.querySelectorAll('p, li, .card, .tech-item');
664-
animate(content, {
668+
animate(content as NodeListOf<HTMLElement>, {
665669
opacity: { from: 0, to: 1 },
666670
translateY: { from: 20, to: 0 },
667671
delay: stagger(50),

0 commit comments

Comments
 (0)