forked from meet-bhagdev/valkeyforai
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
138 lines (119 loc) · 4.96 KB
/
Copy pathscript.js
File metadata and controls
138 lines (119 loc) · 4.96 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
// ============================================
// VALKEY FOR AI — Interactions & Animations
// ============================================
// --- Theme Toggle (Light/Dark) ---
function toggleTheme() {
const body = document.body;
const isLight = body.classList.toggle('light');
localStorage.setItem('theme', isLight ? 'light' : 'dark');
updateThemeIcon(isLight);
}
function updateThemeIcon(isLight) {
const icon = document.getElementById('themeIcon');
if (!icon) return;
if (isLight) {
icon.innerHTML = '<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>';
} else {
icon.innerHTML = '<circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>';
}
}
// Restore saved theme on load
(function() {
const saved = localStorage.getItem('theme');
if (saved === 'light') {
document.body.classList.add('light');
updateThemeIcon(true);
}
})();
document.addEventListener('DOMContentLoaded', () => {
// --- Scroll Animations (Intersection Observer) ---
const animElements = document.querySelectorAll('.anim-fade-up');
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
const delay = entry.target.dataset.delay || 0;
setTimeout(() => {
entry.target.classList.add('visible');
}, parseInt(delay));
observer.unobserve(entry.target);
}
});
}, {
threshold: 0.1,
rootMargin: '0px 0px -40px 0px'
});
animElements.forEach((el) => observer.observe(el));
// --- Sticky Nav with Blur ---
const nav = document.getElementById('nav');
let lastScroll = 0;
const handleScroll = () => {
const scrollY = window.scrollY;
if (scrollY > 20) {
nav.classList.add('scrolled');
} else {
nav.classList.remove('scrolled');
}
lastScroll = scrollY;
};
window.addEventListener('scroll', handleScroll, { passive: true });
handleScroll();
// --- Mobile Menu Toggle ---
const mobileToggle = document.getElementById('mobileToggle');
const navLinks = document.querySelector('.nav-links');
if (mobileToggle) {
mobileToggle.addEventListener('click', () => {
navLinks.classList.toggle('open');
mobileToggle.classList.toggle('active');
});
// Close menu on link click
navLinks.querySelectorAll('a').forEach((link) => {
link.addEventListener('click', () => {
navLinks.classList.remove('open');
mobileToggle.classList.remove('active');
});
});
}
// --- Smooth Scroll for Anchor Links ---
document.querySelectorAll('a[href^="#"]').forEach((anchor) => {
anchor.addEventListener('click', (e) => {
const targetId = anchor.getAttribute('href');
if (targetId === '#') return;
const target = document.querySelector(targetId);
if (target) {
e.preventDefault();
const navHeight = nav.offsetHeight;
const targetPosition = target.getBoundingClientRect().top + window.scrollY - navHeight - 20;
window.scrollTo({
top: targetPosition,
behavior: 'smooth'
});
}
});
});
// --- Parallax-like effect on hero gradient ---
const heroGradient = document.querySelector('.hero-gradient');
if (heroGradient) {
window.addEventListener('mousemove', (e) => {
const x = (e.clientX / window.innerWidth - 0.5) * 20;
const y = (e.clientY / window.innerHeight - 0.5) * 20;
heroGradient.style.transform = `translate(${x}px, ${y}px)`;
}, { passive: true });
}
// --- Card tilt micro-interaction ---
const cards = document.querySelectorAll('.bento-card, .arch-card');
cards.forEach((card) => {
card.addEventListener('mousemove', (e) => {
const rect = card.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
const centerX = rect.width / 2;
const centerY = rect.height / 2;
const rotateX = (y - centerY) / centerY * -3;
const rotateY = (x - centerX) / centerX * 3;
card.style.transform = `perspective(1000px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) translateY(-4px)`;
});
card.addEventListener('mouseleave', () => {
card.style.transform = '';
});
});
});