-
Notifications
You must be signed in to change notification settings - Fork 6
/
app.js
35 lines (25 loc) · 1002 Bytes
/
app.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
(function (){
let socials = document.querySelectorAll('.social div')
socials.forEach(function(social, index) {
social.style.animation = `moveIn 1s ease-in-out forwards $(index/5)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');
}
} )
}())