-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
79 lines (61 loc) · 2.47 KB
/
script.js
File metadata and controls
79 lines (61 loc) · 2.47 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
window.addEventListener('scroll', function() {
const navbar = document.getElementById('navbar');
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
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',
block: 'start'
});
}
});
});
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
}
});
}, observerOptions);
document.querySelectorAll('.fade-in').forEach(el => {
observer.observe(el);
});
document.querySelector('.contact-form').addEventListener('submit', function(e) {
setTimeout(() => {
alert('Thank you for your message! I\'ll get back to you soon.');
}, 1000);
});
function createParticle() {
const particle = document.createElement('div');
particle.style.position = 'absolute';
particle.style.width = '4px';
particle.style.height = '4px';
particle.style.background = 'rgba(102, 126, 234, 0.5)';
particle.style.borderRadius = '50%';
particle.style.pointerEvents = 'none';
const hero = document.querySelector('.hero');
const rect = hero.getBoundingClientRect();
particle.style.left = Math.random() * rect.width + 'px';
particle.style.top = Math.random() * rect.height + 'px';
hero.appendChild(particle);
particle.animate([
{ transform: 'translate(0, 0)', opacity: 1 },
{ transform: `translate(${Math.random() * 100 - 50}px, ${Math.random() * 100 - 50}px)`, opacity: 0 }
], {
duration: 3000 + Math.random() * 2000,
easing: 'ease-out'
}).onfinish = () => particle.remove();
}
setInterval(createParticle, 500);