-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
96 lines (80 loc) · 2.84 KB
/
script.js
File metadata and controls
96 lines (80 loc) · 2.84 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
// Smooth scroll reveal animations
function revealOnScroll() {
const reveals = document.querySelectorAll('.work-item, .skill-category, .contact-method');
reveals.forEach(element => {
const elementTop = element.getBoundingClientRect().top;
const elementVisible = 150;
if (elementTop < window.innerHeight - elementVisible) {
element.classList.add('reveal', 'active');
}
});
}
// Initialize reveal animation
window.addEventListener('scroll', revealOnScroll);
window.addEventListener('load', () => {
revealOnScroll();
document.querySelectorAll('.work-item, .skill-category, .contact-method').forEach(el => {
el.classList.add('reveal');
});
});
// Smooth scroll for navigation links
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'
});
}
});
});
// Add active state to nav links on scroll
const sections = document.querySelectorAll('section[id]');
const navLinks = document.querySelectorAll('.nav-link');
function setActiveNavLink() {
let current = '';
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.clientHeight;
if (window.scrollY >= sectionTop - 200) {
current = section.getAttribute('id');
}
});
navLinks.forEach(link => {
link.classList.remove('active');
if (link.getAttribute('href') === `#${current}`) {
link.classList.add('active');
}
});
}
window.addEventListener('scroll', setActiveNavLink);
// Parallax effect for floating cards
window.addEventListener('scroll', () => {
const scrolled = window.scrollY;
const cards = document.querySelectorAll('.floating-card');
cards.forEach((card, index) => {
const speed = 0.05 + (index * 0.02);
const yPos = -(scrolled * speed);
card.style.transform += ` translateY(${yPos}px)`;
});
});
// Custom cursor effect (optional enhancement)
const cursor = document.createElement('div');
cursor.className = 'custom-cursor';
document.body.appendChild(cursor);
document.addEventListener('mousemove', (e) => {
cursor.style.left = e.clientX + 'px';
cursor.style.top = e.clientY + 'px';
});
// Add hover effect for interactive elements
const interactiveElements = document.querySelectorAll('a, button, .work-item');
interactiveElements.forEach(element => {
element.addEventListener('mouseenter', () => {
cursor.classList.add('cursor-hover');
});
element.addEventListener('mouseleave', () => {
cursor.classList.remove('cursor-hover');
});
});