-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
161 lines (134 loc) · 4.83 KB
/
script.js
File metadata and controls
161 lines (134 loc) · 4.83 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
// Theme Toggle Functionality
const themeToggle = document.getElementById('theme-toggle');
const body = document.body;
const themeIcon = themeToggle.querySelector('i');
// Check for saved theme preference or default to light mode
const savedTheme = localStorage.getItem('theme') || 'light';
if (savedTheme === 'dark') {
body.classList.add('dark-mode');
themeIcon.classList.remove('fa-sun');
themeIcon.classList.add('fa-moon');
}
// Toggle theme function
function toggleTheme() {
body.classList.toggle('dark-mode');
if (body.classList.contains('dark-mode')) {
themeIcon.classList.remove('fa-sun');
themeIcon.classList.add('fa-moon');
localStorage.setItem('theme', 'dark');
} else {
themeIcon.classList.remove('fa-moon');
themeIcon.classList.add('fa-sun');
localStorage.setItem('theme', 'light');
}
}
// Event listener for theme toggle
themeToggle.addEventListener('click', toggleTheme);
// Mobile Navigation Toggle
const hamburger = document.querySelector('.hamburger');
const navLinks = document.querySelector('.nav-links');
hamburger.addEventListener('click', () => {
hamburger.classList.toggle('active');
navLinks.classList.toggle('active');
});
// Close mobile menu when clicking on a link
document.querySelectorAll('.nav-links a').forEach(link => {
link.addEventListener('click', () => {
hamburger.classList.remove('active');
navLinks.classList.remove('active');
});
});
// 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 - 80,
behavior: 'smooth'
});
}
});
});
// Add scroll effect to navbar
window.addEventListener('scroll', () => {
const header = document.querySelector('.header');
if (window.scrollY > 50) {
header.style.boxShadow = 'var(--shadow)';
} else {
header.style.boxShadow = 'none';
}
});
// Scroll animations
function checkScroll() {
const elements = document.querySelectorAll('.scroll-animate');
elements.forEach(element => {
const elementTop = element.getBoundingClientRect().top;
const windowHeight = window.innerHeight;
if (elementTop < windowHeight - 100) {
element.classList.add('visible');
}
});
}
// Initialize scroll animations
document.addEventListener('DOMContentLoaded', () => {
// Add scroll-animate class to elements that should animate on scroll
const animateElements = document.querySelectorAll('.value-card, .journey-card, .section-header');
animateElements.forEach(el => {
el.classList.add('scroll-animate');
});
// Check scroll position on load
checkScroll();
});
// Listen for scroll events
window.addEventListener('scroll', checkScroll);
// Button hover effects enhancement
document.querySelectorAll('.btn').forEach(button => {
button.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-3px)';
});
button.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0)';
});
});
// Card hover effects
document.querySelectorAll('.value-card, .journey-card').forEach(card => {
card.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-10px)';
});
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0)';
});
});
// Add loading animation
window.addEventListener('load', () => {
document.body.classList.add('loaded');
// Add a slight delay to ensure all content is rendered
setTimeout(() => {
const loadingElements = document.querySelectorAll('.animate-fade-in, .animate-slide-up, .animate-card');
loadingElements.forEach(el => {
el.style.animationPlayState = 'running';
});
}, 300);
});
// Enhanced theme toggle with ripple effect
themeToggle.addEventListener('click', function(e) {
// Create ripple element
const ripple = document.createElement('span');
const rect = this.getBoundingClientRect();
const size = Math.max(rect.width, rect.height);
const x = e.clientX - rect.left - size / 2;
const y = e.clientY - rect.top - size / 2;
ripple.style.width = ripple.style.height = size + 'px';
ripple.style.left = x + 'px';
ripple.style.top = y + 'px';
ripple.classList.add('ripple');
this.appendChild(ripple);
// Remove ripple after animation
setTimeout(() => {
ripple.remove();
}, 600);
});