-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
150 lines (125 loc) · 5.04 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
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
146
147
148
149
150
const menuBox = document.querySelector(".menu-box");
const menuIcons = document.querySelectorAll(".menu-icon");
const menuOpen = document.querySelector("#menu-open");
const menuClose = document.querySelector("#menu-close");
const serviceCardsOuterContainer = document.querySelector(".service-cards-outer-container");
let serviceCards = document.querySelectorAll('.service-card-outer-container');
const largeScreenQuery = window.matchMedia("(min-width: 1280px)");
const portfolioItemsEven = document.querySelectorAll(".portfolio-item-container.even");
const portfolioItemsOdd = document.querySelectorAll(".portfolio-item-container.odd");
const teamWomanImage = document.querySelector('#woman');
const teamManNoGlassesImage = document.querySelector('#man-no-glasses');
const teamManGlassesImage = document.querySelector('#man-glasses');
const teamTextContent = document.querySelector('#team-text-content');
const testimonialText = document.querySelector('#testimonial-text');
const testimonialImage = document.querySelector('#testimonials-image-content-flex-container');
const desktopNavTitleContainer = document.querySelector('#desktop-nav');
const heroTitle = document.querySelector('#title');
heroTitle.classList.add('animate__zoomInDown');
desktopNavTitleContainer.style.opacity = '0'
setTimeout(() => {
desktopNavTitleContainer.style.opacity = '1'
desktopNavTitleContainer.classList.add('animate__zoomInDown');
}, 400);
menuIcons.forEach(menuIcon => {
menuIcon.onclick = function(){
menuBox.classList.toggle('open-menu');
menuOpen.classList.toggle('open')
menuClose.classList.toggle('open')
}
});
if(largeScreenQuery.matches){
//service cards scroll staggered slide in up animation
let serviceCardsObserver = new IntersectionObserver((entries) => {
entries.forEach((entry, index) => {
setTimeout(() => {
entry.target.classList.toggle('animate__fadeInUpBig', entry.isIntersecting)
if(entry.isIntersecting) serviceCardsObserver.unobserve(entry.target)
}, 300 * (index + 1));
})
},
{
threshold: 0,
rootMargin: '-40px 0px 0px 0px'
});
serviceCards.forEach(serviceCard => {
serviceCardsObserver.observe(serviceCard);
})
//portfolio item odd scroll slide in right animation
const portfolioItemsEvenObserver = new IntersectionObserver(entries => {
entries.forEach(entry => {
if(!entry.isIntersecting) return;
entry.target.classList.add('animate__slideInRight');
portfolioItemsEvenObserver.unobserve(entry.target);
})
}, );
portfolioItemsEven.forEach(portfolioItem => {
portfolioItemsEvenObserver.observe(portfolioItem);
});
//portfolio item odd scroll slide in left animation
const portfolioItemsOddObserver = new IntersectionObserver(entries => {
entries.forEach(entry => {
if(!entry.isIntersecting) return;
entry.target.classList.add('animate__slideInLeft');
portfolioItemsOddObserver.unobserve(entry.target);
})
}, );
portfolioItemsOdd.forEach(portfolioItem => {
portfolioItemsOddObserver.observe(portfolioItem);
});
}
//Team section Intersection Observer scroll animations
const teamManNoGlassesObserver = new IntersectionObserver(entries => {
entries.forEach(entry => {
if(!entry.isIntersecting) return;
entry.target.classList.add('animate__slideInRight');
teamManNoGlassesObserver.unobserve(entry.target);
})
})
teamManNoGlassesObserver.observe(teamManNoGlassesImage);
const teamWomanObserver = new IntersectionObserver(entries => {
entries.forEach(entry => {
if(!entry.isIntersecting) return;
entry.target.classList.add('animate__slideInLeft');
teamWomanObserver.unobserve(entry.target);
})
})
teamWomanObserver.observe(teamWomanImage);
const teamManGlassesObserver = new IntersectionObserver(entries => {
entries.forEach(entry => {
if(!entry.isIntersecting) return;
entry.target.classList.add('animate__slideInRight');
teamManGlassesObserver.unobserve(entry.target);
})
})
teamManGlassesObserver.observe(teamManGlassesImage);
const teamTextContentObserver = new IntersectionObserver(entries => {
entries.forEach(entry => {
if(!entry.isIntersecting) {
entry.target.style.opacity = 0;
} else {
entry.target.style.opacity = 1;
entry.target.classList.add('animate__flipInY');
teamTextContentObserver.unobserve(entry.target);
}
});
}, {
threshold: 0.9
});
teamTextContentObserver.observe(teamTextContent);
const testimonialParagraphObserver = new IntersectionObserver(entries => {
entries.forEach(entry => {
if(!entry.isIntersecting) return;
entry.target.classList.add('animate__slideInRight');
});
}, {
threshold: 0.1
});
testimonialParagraphObserver.observe(testimonialText);
const testimonialImageObserver = new IntersectionObserver(entries => {
entries.forEach(entry => {
if(!entry.isIntersecting) return;
entry.target.classList.add('animate__slideInLeft');
});
});
testimonialImageObserver.observe(testimonialImage);