-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
89 lines (77 loc) · 2.7 KB
/
scripts.js
File metadata and controls
89 lines (77 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Scroll Trigger Animation
document.addEventListener('scroll', () => {
const sections = document.querySelectorAll('.section');
sections.forEach(section => {
const sectionPosition = section.getBoundingClientRect().top;
if (sectionPosition < window.innerHeight / 1.5) {
section.classList.add('visible');
} else {
section.classList.remove('visible');
}
});
});
AOS.init();
// Cursor Effect - Custom Cursor Animation (optional)
document.querySelectorAll('a').forEach(link => {
link.addEventListener('mouseover', () => {
document.body.style.cursor = 'url(https://example.com/hover-cursor.png), auto';
});
link.addEventListener('mouseout', () => {
document.body.style.cursor = 'url(https://example.com/normal-cursor.png), auto';
});
});
// Words to animate
const words = ["AI/ML Enthusiast", "Software Engineer", "Content creator", "Innovator", "Problem Solver"];
let currentWordIndex = 0;
let currentCharIndex = 0;
const animatedTextElement = document.querySelector(".animated-text");
function typeEffect() {
if (currentCharIndex <= words[currentWordIndex].length) {
// Display one character at a time
animatedTextElement.textContent = words[currentWordIndex].slice(0, currentCharIndex);
currentCharIndex++;
setTimeout(typeEffect, 100); // Typing speed
} else {
setTimeout(deleteEffect, 1500); // Pause before deleting
}
}
function deleteEffect() {
if (currentCharIndex >= 0) {
// Remove one character at a time
animatedTextElement.textContent = words[currentWordIndex].slice(0, currentCharIndex);
currentCharIndex--;
setTimeout(deleteEffect, 50); // Deleting speed
} else {
// Move to the next word
currentWordIndex = (currentWordIndex + 1) % words.length;
setTimeout(typeEffect, 500); // Start typing the next word
}
}
// Scroll Trigger for Skills Section
const skills = document.querySelectorAll('.skill');
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add('active');
}
});
});
skills.forEach((skill) => observer.observe(skill));
document.addEventListener('DOMContentLoaded', () => {
const animateElements = document.querySelectorAll('.experience-item');
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add('active');
}
});
},
{
threshold: 0.2,
}
);
animateElements.forEach((el) => observer.observe(el));
});
// Start the animation
typeEffect();