-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynamic.js
More file actions
171 lines (145 loc) · 6.56 KB
/
dynamic.js
File metadata and controls
171 lines (145 loc) · 6.56 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*
TemplateMo 593 personal shape
https://templatemo.com/tm-593-personal-shape
*/
// JavaScript Document
// Mobile menu functionality
const mobileMenuToggle = document.getElementById('mobileMenuToggle');
const mobileMenu = document.getElementById('mobileMenu');
const mobileNavLinks = document.querySelectorAll('.mobile-nav-links a');
mobileMenuToggle.addEventListener('click', () => {
mobileMenuToggle.classList.toggle('active');
mobileMenu.classList.toggle('active');
document.body.style.overflow = mobileMenu.classList.contains('active') ? 'hidden' : 'auto';
});
// Close mobile menu when clicking on links
mobileNavLinks.forEach(link => {
link.addEventListener('click', () => {
mobileMenuToggle.classList.remove('active');
mobileMenu.classList.remove('active');
document.body.style.overflow = 'auto';
});
});
// Close mobile menu when clicking outside
document.addEventListener('click', (e) => {
if (!mobileMenuToggle.contains(e.target) && !mobileMenu.contains(e.target)) {
mobileMenuToggle.classList.remove('active');
mobileMenu.classList.remove('active');
document.body.style.overflow = 'auto';
}
});
// Navbar scroll effect
window.addEventListener('scroll', () => {
const navbar = document.getElementById('navbar');
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// Enhanced Intersection Observer for scroll animations
const observerOptions = {
threshold: 0.15,
rootMargin: '0px 0px -80px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate');
}
});
}, observerOptions);
// Staggered animation for portfolio items
const portfolioObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const items = entry.target.querySelectorAll('.portfolio-item');
items.forEach((item, index) => {
setTimeout(() => {
item.classList.add('animate');
}, index * 150);
});
}
});
}, { threshold: 0.1 });
// Observe all animation elements
document.addEventListener('DOMContentLoaded', () => {
const animatedElements = document.querySelectorAll('.fade-in, .slide-in-left, .slide-in-right');
animatedElements.forEach(el => observer.observe(el));
const portfolioSection = document.querySelector('.portfolio-grid');
if (portfolioSection) {
portfolioObserver.observe(portfolioSection);
}
});
// Enhanced smooth scrolling for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
const offsetTop = target.offsetTop - 80;
window.scrollTo({
top: offsetTop,
behavior: 'smooth'
});
}
});
});
// Enhanced form submission with better UX
document.querySelector('.contact-form').addEventListener('submit', (e) => {
e.preventDefault();
const submitBtn = document.querySelector('.submit-btn');
const originalText = submitBtn.textContent;
// Add loading state
submitBtn.textContent = 'Sending...';
submitBtn.disabled = true;
submitBtn.style.background = 'linear-gradient(135deg, #94a3b8, #64748b)';
// Simulate form submission with better feedback
setTimeout(() => {
submitBtn.textContent = 'Message Sent! ✓';
submitBtn.style.background = 'linear-gradient(135deg, #10b981, #059669)';
// Show success animation
submitBtn.style.transform = 'scale(1.05)';
setTimeout(() => {
submitBtn.style.transform = 'scale(1)';
}, 200);
setTimeout(() => {
submitBtn.textContent = originalText;
submitBtn.disabled = false;
submitBtn.style.background = '';
document.querySelector('.contact-form').reset();
}, 3000);
}, 2000);
});
// Enhanced parallax effect for hero background
let ticking = false;
function updateParallax() {
const scrolled = window.pageYOffset;
const hero = document.querySelector('.hero');
const rate = scrolled * -0.3;
hero.style.transform = `translateY(${rate}px)`;
ticking = false;
}
window.addEventListener('scroll', () => {
if (!ticking) {
requestAnimationFrame(updateParallax);
ticking = true;
}
});
// Add subtle hover effects to skill tags
document.querySelectorAll('.skill-tag').forEach(tag => {
tag.addEventListener('mouseenter', () => {
tag.style.transform = 'translateY(-2px) scale(1.05)';
});
tag.addEventListener('mouseleave', () => {
tag.style.transform = 'translateY(0) scale(1)';
});
});
// Keyboard navigation for accessibility
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && mobileMenu.classList.contains('active')) {
mobileMenuToggle.classList.remove('active');
mobileMenu.classList.remove('active');
document.body.style.overflow = 'auto';
}
});