-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
67 lines (58 loc) · 2.18 KB
/
script.js
File metadata and controls
67 lines (58 loc) · 2.18 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
document.addEventListener('DOMContentLoaded', () => {
// Typing effect for the main heading
const textElement = document.getElementById('typing-text');
const originalText = textElement.innerText;
textElement.innerText = '';
let i = 0;
const typeWriter = () => {
if (i < originalText.length) {
textElement.innerText += originalText.charAt(i);
i++;
setTimeout(typeWriter, 100);
}
};
// Start typing after a short delay
setTimeout(typeWriter, 500);
// Cursor Glow Effect
const glow = document.querySelector('.cursor-glow');
document.addEventListener('mousemove', (e) => {
glow.style.left = e.clientX + 'px';
glow.style.top = e.clientY + 'px';
});
// Smooth Scrolling for nav links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
window.scrollTo({
top: targetElement.offsetTop - 80,
behavior: 'smooth'
});
}
});
});
// Add scroll reveal animation (simple version)
const revealOnScroll = () => {
const sections = document.querySelectorAll('section');
const triggerBottom = window.innerHeight * 0.8;
sections.forEach(section => {
const sectionTop = section.getBoundingClientRect().top;
if (sectionTop < triggerBottom) {
section.style.opacity = '1';
section.style.transform = 'translateY(0)';
section.style.transition = 'all 0.8s ease-out';
}
});
};
// Initial styles for reveal
document.querySelectorAll('section').forEach(section => {
if (section.id !== 'hero') {
section.style.opacity = '0';
section.style.transform = 'translateY(30px)';
}
});
window.addEventListener('scroll', revealOnScroll);
revealOnScroll(); // Run once on load
});