-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
36 lines (25 loc) · 1 KB
/
script.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
(function () {
let socials = document.querySelectorAll('.social div')
socials.forEach(function(social, index) {
social.style.animation = `moveIn .6s cubic-bezier(.51,.92,.24,1.15) forwards ${index/7 + 0.2}s`
})
let rocketPieces = document.querySelectorAll('.rocket-body span')
let rocket = document.querySelector('.rocket')
let triggerStart = window.innerHeight / 5;
let rocketOffsetTop = rocket.offsetTop;
let thirdOffsetTop = rocketPieces[2].offsetTop;
document.addEventListener('scroll', (e) => {
if(window.scrollY > (rocketOffsetTop - triggerStart)) {
rocketPieces[0].classList.add('active');
rocketPieces[1].classList.add('active');
} else {
rocketPieces[0].classList.remove('active');
rocketPieces[1].classList.remove('active');
}
if(window.scrollY > (thirdOffsetTop - triggerStart)) {
rocketPieces[2].classList.add('active');
} else {
rocketPieces[2].classList.remove('active');
}
})
}())