-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
115 lines (99 loc) · 3.94 KB
/
script.js
File metadata and controls
115 lines (99 loc) · 3.94 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
document.addEventListener('DOMContentLoaded', () => {
const html = document.documentElement;
const themeToggle = document.getElementById('theme-toggle');
// Initialize theme
const savedTheme = localStorage.getItem('theme') || 'light';
html.setAttribute('data-theme', savedTheme);
// Theme toggle functionality - single event listener
themeToggle.addEventListener('click', () => {
const currentTheme = html.getAttribute('data-theme');
const newTheme = currentTheme === 'light' ? 'dark' : 'light';
// Add rotation animation to the toggle button
const toggleIcon = themeToggle.querySelector('.toggle-icon');
toggleIcon.style.transform = `rotate(${currentTheme === 'light' ? '180' : '0'}deg)`;
html.setAttribute('data-theme', newTheme);
localStorage.setItem('theme', newTheme);
});
// Handle active state for navigation items
const navItems = document.querySelectorAll('.bottom-nav .nav-item');
navItems.forEach(item => {
item.addEventListener('click', () => {
// Don't add active class to theme toggle or team link
if (!item.id.includes('theme-toggle') && !item.getAttribute('href').includes('team')) {
navItems.forEach(nav => nav.classList.remove('active'));
item.classList.add('active');
}
});
});
// Smooth scroll functionality
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'
});
}
});
});
// Update active state based on scroll position
window.addEventListener('scroll', () => {
const sections = document.querySelectorAll('section');
const scrollPosition = window.scrollY + window.innerHeight / 2;
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.offsetHeight;
const sectionId = section.getAttribute('id');
if (scrollPosition >= sectionTop && scrollPosition < sectionTop + sectionHeight) {
navItems.forEach(item => {
item.classList.remove('active');
if (item.getAttribute('href') === `#${sectionId}`) {
item.classList.add('active');
}
});
}
});
});
// Add route handling for team page
const teamNavItem = document.querySelector('.nav-item[href="#team"]');
teamNavItem.addEventListener('click', (e) => {
e.preventDefault();
window.location.href = '/team';
});
});
// Check for saved theme preference
const savedTheme = localStorage.getItem('theme');
if (savedTheme) {
document.documentElement.setAttribute('data-theme', savedTheme);
}
// Initialize AOS (Animate On Scroll)
AOS.init({
duration: 800,
offset: 100,
once: true
});
// Smooth scroll for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Add scroll class to navbar
const navbar = document.querySelector('.navbar');
window.addEventListener('scroll', () => {
if (window.scrollY > 100) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// Optional: Add parallax effect to hero section
window.addEventListener('scroll', () => {
const hero = document.querySelector('.hero');
const scrolled = window.pageYOffset;
hero.style.transform = `translateY(${scrolled * 0.5}px)`;
});