-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
69 lines (55 loc) · 1.78 KB
/
main.js
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
// Custom cursor with smooth movement
const cursor = document.createElement('div');
cursor.classList.add('cursor');
document.body.appendChild(cursor);
let cursorX = 0;
let cursorY = 0;
let currentX = 0;
let currentY = 0;
document.addEventListener('mousemove', (e) => {
cursorX = e.clientX;
cursorY = e.clientY;
});
// Smooth cursor animation
function animateCursor() {
const ease = 0.15;
currentX += (cursorX - currentX) * ease;
currentY += (cursorY - currentY) * ease;
cursor.style.left = currentX + 'px';
cursor.style.top = currentY + 'px';
requestAnimationFrame(animateCursor);
}
animateCursor();
// Add hover effect to cursor
document.querySelectorAll('a, button, .skill-card').forEach(element => {
element.addEventListener('mouseenter', () => cursor.classList.add('hover'));
element.addEventListener('mouseleave', () => cursor.classList.remove('hover'));
});
// Splash screen
const splashScreen = document.querySelector('.splash-screen');
if (splashScreen) {
setTimeout(() => {
splashScreen.style.opacity = '0';
setTimeout(() => {
splashScreen.style.display = 'none';
}, 500);
}, 2500);
}
// Fade-in animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
observer.unobserve(entry.target);
}
});
}, observerOptions);
document.querySelectorAll('.fade-in').forEach(element => {
observer.observe(element);
});
// Smooth scroll behavior
document.documentElement.style.scrollBehavior = 'smooth';