-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
110 lines (95 loc) · 4.04 KB
/
Copy pathscript.js
File metadata and controls
110 lines (95 loc) · 4.04 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
// Elegant JavaScript for the personal webpage
document.addEventListener('DOMContentLoaded', function() {
// Smooth scroll 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) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Mobile menu toggle
const mobileToggle = document.querySelector('.mobile-menu-toggle');
const navMenu = document.querySelector('.nav-menu');
if (mobileToggle && navMenu) {
mobileToggle.addEventListener('click', function() {
navMenu.classList.toggle('active');
// Toggle hamburger icon
const spans = this.querySelectorAll('span');
spans.forEach(span => span.classList.toggle('active'));
});
// Close menu when clicking on a link
document.querySelectorAll('.nav-menu a').forEach(link => {
link.addEventListener('click', () => {
navMenu.classList.remove('active');
const spans = mobileToggle.querySelectorAll('span');
spans.forEach(span => span.classList.remove('active'));
});
});
}
// Navbar scroll effect
const navbar = document.querySelector('.navbar');
if (navbar) {
window.addEventListener('scroll', function() {
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
}
// Enhanced animations for all elements
const allElements = document.querySelectorAll('.hero-name, .hero-title, .hero-description, .hero-details, .hero-actions, .about-text, .about-stats, .about-skills');
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -10% 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
allElements.forEach((element, index) => {
element.style.opacity = '0';
element.style.transform = 'translateY(30px)';
element.style.transition = `opacity 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) ${index * 0.15}s, transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) ${index * 0.15}s`;
observer.observe(element);
});
// Enhanced hover effects for interactive elements
document.querySelectorAll('.skill-tag, .detail-item, .stat-item').forEach(element => {
element.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-5px) scale(1.02)';
});
element.addEventListener('mouseleave', function() {
if (this.classList.contains('skill-tag')) {
this.style.transform = 'translateY(0) scale(1)';
} else {
this.style.transform = 'translateY(0)';
}
});
});
// Parallax effect for background elements
window.addEventListener('scroll', function() {
const scrolled = window.pageYOffset;
const parallaxElements = document.querySelectorAll('.hero::before, .about::before');
parallaxElements.forEach(element => {
element.style.transform = `translateY(${scrolled * 0.1}px)`;
});
});
// Smooth page loading effect with stagger
document.body.style.opacity = '0';
document.body.style.transform = 'translateY(20px)';
document.body.style.transition = 'opacity 0.8s ease, transform 0.8s ease';
setTimeout(() => {
document.body.style.opacity = '1';
document.body.style.transform = 'translateY(0)';
}, 200);
});