-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
138 lines (120 loc) · 3.84 KB
/
Copy pathscript.js
File metadata and controls
138 lines (120 loc) · 3.84 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
document.addEventListener('DOMContentLoaded', function() {
// Mobile menu toggle
const hamburger = document.querySelector('.hamburger');
const navLinks = document.querySelector('.nav-links');
const navbar = document.querySelector('.navbar');
// Mobile menu toggle
hamburger.addEventListener('click', function() {
this.classList.toggle('active');
navLinks.classList.toggle('active');
navbar.classList.toggle('menu-open');
});
// Close mobile menu when clicking on a link
document.querySelectorAll('.nav-link').forEach(link => {
link.addEventListener('click', () => {
hamburger.classList.remove('active');
navLinks.classList.remove('active');
navbar.classList.remove('menu-open');
});
});
// Navbar scroll effect
window.addEventListener('scroll', function() {
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// Enhanced scroll reveal animation
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -100px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('show');
// Add animation delay based on data-delay attribute
const delay = entry.target.dataset.delay || 0;
entry.target.style.animationDelay = `${delay}ms`;
}
});
}, observerOptions);
document.querySelectorAll('.hidden').forEach(el => {
observer.observe(el);
});
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
if (targetId === '#') return;
const targetElement = document.querySelector(targetId);
if (targetElement) {
window.scrollTo({
top: targetElement.offsetTop - navbar.offsetHeight,
behavior: 'smooth'
});
}
});
});
// Typewriter effect for hero subtitle
const heroSubtitle = document.querySelector('.hero-subtitle');
if (heroSubtitle) {
const text = heroSubtitle.textContent;
heroSubtitle.textContent = '';
let i = 0;
const typeWriter = () => {
if (i < text.length) {
heroSubtitle.textContent += text.charAt(i);
i++;
setTimeout(typeWriter, 100);
}
};
setTimeout(typeWriter, 1000);
}
// Skill card animation on hover
document.querySelectorAll('.skill-card').forEach(card => {
card.addEventListener('mouseenter', () => {
card.style.transform = 'translateY(-10px)';
const icon = card.querySelector('.skill-icon');
if (icon) {
icon.style.transform = 'scale(1.2)';
}
});
card.addEventListener('mouseleave', () => {
card.style.transform = 'translateY(0)';
const icon = card.querySelector('.skill-icon');
if (icon) {
icon.style.transform = 'scale(1)';
}
});
});
// Project card hover effect (simplified one-time animation)
document.querySelectorAll('.project-card').forEach(card => {
card.addEventListener('mouseenter', () => {
card.style.transform = 'translateY(-10px)';
card.style.boxShadow = 'var(--shadow-lg)';
});
card.addEventListener('mouseleave', () => {
card.style.transform = 'translateY(0)';
card.style.boxShadow = 'var(--shadow)';
});
});
scrollToTopBtn.addEventListener('click', () => {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
// Loading screen removal
const loadingScreen = document.querySelector('.loading-screen');
if (loadingScreen) {
setTimeout(() => {
loadingScreen.style.opacity = '0';
setTimeout(() => {
loadingScreen.remove();
}, 500);
}, 1000);
}
});