-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
26 lines (24 loc) · 924 Bytes
/
index.js
File metadata and controls
26 lines (24 loc) · 924 Bytes
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
// js/script.js
document.addEventListener('DOMContentLoaded', () => {
// Floating animation observer
const floatObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.animation = 'float 6s ease-in-out infinite';
}
});
}, { threshold: 0.1 });
document.querySelectorAll('.floating-img').forEach(img => {
floatObserver.observe(img);
});
// Card hover effect
document.querySelectorAll('.card').forEach(card => {
card.addEventListener('mousemove', (e) => {
const rect = card.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
card.style.setProperty('--x', `${x}px`);
card.style.setProperty('--y', `${y}px`);
});
});
});