-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript_v2.js
More file actions
59 lines (50 loc) · 2.09 KB
/
script_v2.js
File metadata and controls
59 lines (50 loc) · 2.09 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
document.addEventListener('DOMContentLoaded', () => {
// Scroll Reveal Animation
const revealElements = document.querySelectorAll('.reveal');
const revealObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('active');
}
});
}, {
threshold: 0.1
});
revealElements.forEach(el => revealObserver.observe(el));
// Smooth Scroll for Anchors
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Dynamic Title (optional easter egg)
const titles = ["Product Manager", "Creative Founder", "Polymath", "Dreamer", "Executor"];
let titleIndex = 0;
// Theme Switcher Logic
const themeBtn = document.getElementById('theme-btn');
if (themeBtn) {
// Load saved theme
const savedTheme = localStorage.getItem('theme') || 'dark';
document.documentElement.setAttribute('data-theme', savedTheme);
updateThemeIcon(savedTheme);
themeBtn.addEventListener('click', () => {
const currentTheme = document.documentElement.getAttribute('data-theme');
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
document.documentElement.setAttribute('data-theme', newTheme);
localStorage.setItem('theme', newTheme);
updateThemeIcon(newTheme);
});
}
function updateThemeIcon(theme) {
if (!themeBtn) return;
// Simple text or SVG swap could go here.
// For now, let's just toggle a class or simpler emoji
themeBtn.textContent = theme === 'dark' ? '☀' : '☾';
}
const subElement = document.querySelector('.hero-sub-text');
// Simple typewriter effect or fade could go here if requested,
// keeping it simple for now to focus on CSS animations.
});