-
Notifications
You must be signed in to change notification settings - Fork 89
/
daveScroll.js
60 lines (45 loc) · 1.66 KB
/
daveScroll.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
const scroll = (content, style) => {
const serviceOptons = {
rootMargin: '-150px 0px -150px 0px'
};
const serviceObsever = new IntersectionObserver((entries, serviceObsever, appearOnScroll) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
if (style === 'bottom') {
content.style.animation = 'bottom .7s forwards ease-in-out';
content.style.visibility = 'visible';
serviceObsever.unobserve(content);
}
if (style === 'top') {
content.style.animation = 'top .7s forwards ease-in-out';
content.style.visibility = 'visible';
serviceObsever.unobserve(content);
}
if (style === 'left') {
content.style.animation = 'left .7s forwards ease-in-out';
content.style.visibility = 'visible';
serviceObsever.unobserve(content);
}
if (style === 'right') {
content.style.animation = 'right .7s forwards ease-in-out';
content.style.visibility = 'visible';
serviceObsever.unobserve(content);
}
if (style === 'pop') {
content.style.animation = 'pop .7s forwards ease-in-out';
content.style.visibility = 'visible';
serviceObsever.unobserve(content);
}
if (style === 'rotate') {
content.style.animation = 'rotate .7s forwards ease-in-out';
content.style.visibility = 'visible';
serviceObsever.unobserve(content);
}
} else {
content.style.animation = 'none';
content.style.visibility = 'hidden';
}
})
}, serviceOptons);
serviceObsever.observe(content);
};