-
Notifications
You must be signed in to change notification settings - Fork 0
/
scrollAnimation.js
145 lines (97 loc) · 4.72 KB
/
scrollAnimation.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// this file is for handeling scroll animation
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
spans.forEach(span =>
{
if(entry.isIntersecting){
span.classList.add('animate')
}else{
span.classList.remove('animate')
}
})
})
})
const skillContainer = document.querySelector('.skills-container')
const spans = document.querySelectorAll('.bar span')
observer.observe(skillContainer)
// using scroll reveal to handle the scroll animation of each section
// get header of each section
const skillsHeader = document.querySelector('.skills-header')
const projectHeader = document.querySelector('.project-header')
const backgroundHeader = document.querySelector('.background-header')
const blogHeader = document.querySelector('.blog-header')
const contactHeader = document.querySelector('.contact-header')
// home section
const homeLeft = document.querySelector('.home-left')
const homeRight = document.querySelector('.right')
// strength section
const strength = document.querySelector('.strength')
const strengthColumns = document.querySelectorAll('.strength-column')
// about section
const about = document.querySelector('.about')
const aboutLeft = document.querySelector('.about-left')
const aboutRight = document.querySelector('.about-right')
// skills section
const skillsContainer = document.querySelector('.skills-container')
// projects section
const laptopOne = document.querySelector('.laptop-container-one')
const laptopTwo = document.querySelector('.laptop-container-two')
const laptopThree = document.querySelector('.laptop-container-three')
const laptopFour = document.querySelector('.laptop-container-four')
const textOne = document.querySelector('.project-text-one')
const textTwo = document.querySelector('.project-text-two')
const textThree = document.querySelector('.project-text-three')
const textFour = document.querySelector('.project-text-four')
// background section
const backgroundLeft = document.querySelector('.background-left')
const backgroundRight = document.querySelector('.background-right')
// blog section
const gridContainer = document.querySelector('.grid-container')
const gridItems = document.querySelectorAll('.grid-item')
// contact section
const contactGridContainer = document.querySelector('.contact-grid-container')
const handleScrollReveal = () => {
ScrollReveal({
reset: true,
distance: '10rem',
duration: 2500,
delay: 400
})
// headers
const headers = [skillsHeader, projectHeader, backgroundHeader, blogHeader, contactHeader]
if(window.innerWidth > 991.98){
headers.forEach(header => {
ScrollReveal().reveal(header, {delay: 500, origin: 'left'});
})
// home section
ScrollReveal().reveal(homeLeft, {delay: 600, origin: 'left'});
ScrollReveal().reveal(homeRight, {delay: 600, origin: 'right'});
// strength
ScrollReveal().reveal(strength, {delay: 600, origin: 'bottom'});
ScrollReveal().reveal(strengthColumns, {delay: 500, origin: 'bottom', interval: 200})
// about
ScrollReveal().reveal(about, {delay: 500, origin: 'bottom'});
ScrollReveal().reveal(aboutLeft, {delay: 500, origin: 'left'});
ScrollReveal().reveal(aboutRight, {delay: 500, origin: 'right'});
// skills
ScrollReveal().reveal(skillsContainer, {delay: 400});
//project
ScrollReveal().reveal(laptopOne, {delay: 500, origin: 'right'});
ScrollReveal().reveal(textOne, {delay: 500, origin: 'left'});
ScrollReveal().reveal(laptopTwo, {delay: 500, origin: 'left'});
ScrollReveal().reveal(textTwo, {delay: 500, origin: 'right'});
ScrollReveal().reveal(laptopThree, {delay: 500, origin: 'right'});
ScrollReveal().reveal(textThree, {delay: 500, origin: 'left'});
ScrollReveal().reveal(laptopFour, {delay: 500, origin: 'left'});
ScrollReveal().reveal(textFour, {delay: 500, origin: 'right'});
// background
ScrollReveal().reveal(backgroundLeft, {delay: 500, origin: 'left'});
ScrollReveal().reveal(backgroundRight, {delay: 500, origin: 'right'});
// blog
ScrollReveal().reveal(gridContainer, {delay: 600, origin: 'bottom'});
ScrollReveal().reveal(gridItems, {delay: 500, origin: 'bottom', interval: 200});
// contact
ScrollReveal().reveal(contactGridContainer, {delay: 500, origin: 'bottom'});
}
}
handleScrollReveal()