-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
73 lines (51 loc) · 1.73 KB
/
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
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
let header = document.querySelector('.header');
let site = document.querySelector('.site');
let cta = document.querySelector('.cta');
let imageOverlay = document.querySelector('.image-container').children[0];
let mainImage = document.querySelector('.image-container').children[1];
let links = Array.from(document.querySelectorAll('.link'));
function animate(){
setTimeout(()=>{
header.classList.add('active');
imageOverlay.style.animation = 'slide 1s forwards';
mainImage.style.animation = 'slide-perm 1s forwards';
}, 2000);
setTimeout(()=>{
site.classList.add('active');
cta.classList.add('active');
},3000);
links.forEach(link =>{
setTimeout(()=>{
link.classList.add('active');
},(idx = 200) +2500);
})
}
animate()
let aosElements = Array.from(document.querySelectorAll('.aos'));
window.addEventListener('scroll', _.throttle(scanElements, 50))
function scanElements(){
aosElements.forEach(element => {
if(isVisable(element)){
element.classList.add('active');
}else{
element.classList.remove('active');
}
})
}
function isVisable(element){
const elementDiv = element.getBoundingClientRect();
let distanceFromTop = -300;
return elementDiv.top - window.innerHeight < distanceFromTop? true : false;
}
// function throttle(fn, delay){
// let lastCall = 0;
// return (...arg)=>{
// let context = this;
// let current = new Date().getTime()
// if (current - lastCall < delay){
// return
// }
// lastCall = current;
// return fn.apply(context, ...args)
// }
// }