-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
33 lines (29 loc) · 1.21 KB
/
scripts.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
document.addEventListener('DOMContentLoaded', function() {
const skills = document.querySelectorAll('.skill');
const projects = document.querySelectorAll('.project-card');
function handleScroll() {
const triggerBottom = window.innerHeight / 5 * 4;
skills.forEach(skill => {
const skillTop = skill.getBoundingClientRect().top;
if(skillTop < triggerBottom) {
skill.style.opacity = '1';
skill.style.transform = 'translateY(0)';
} else {
skill.style.opacity = '0';
skill.style.transform = 'translateY(20px)';
}
});
projects.forEach(project => {
const projectTop = project.getBoundingClientRect().top;
if(projectTop < triggerBottom) {
project.style.opacity = '1';
project.style.transform = 'translateY(0)';
} else {
project.style.opacity = '0';
project.style.transform = 'translateY(20px)';
}
});
}
window.addEventListener('scroll', handleScroll);
handleScroll(); // Run on load to show elements already in view
});