-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
59 lines (49 loc) · 1.81 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
document.documentElement.style.scrollBehavior = "smooth"; //scroll-behavior: smooth;
const body = document.body;
//preloader
const preloader = document.querySelector('.preloader');
window.addEventListener('load',()=>{
body.classList.add('preloader-active');
preloader.style.display = "none";
})
//toggle hamburger
const nav = document.querySelector('nav');
const navMenu = document.querySelector('.nav__menu');
const overlay = document.querySelector('.body__overlay');
navMenu.addEventListener('click',()=>{
nav.classList.toggle('active');
if(nav.classList.contains('active')){
overlay.style.background = "hsla(233, 26%, 24%,.5)";
overlay.style.zIndex = "10";
}else{
overlay.style.background = "transparent";
overlay.style.zIndex = "-1";
}
})
// remove box-shadow in laptops and desktops
var x = window.matchMedia("(min-width: 1000px)");
if(x.matches && nav.classList.contains('active')){
nav.classList.remove('active');
}
// transitions on scroll
const fadeFromLeft = document.querySelectorAll('.ffl');
const observer = new IntersectionObserver(entries =>{
entries.forEach(entry=>{
entry.isIntersecting && entry.target.classList.add('ffl-show');
})
})
fadeFromLeft.forEach(el => observer.observe(el));
const fadeFromTop = document.querySelectorAll('.fft');
const observerTwo = new IntersectionObserver(entries =>{
entries.forEach(entry=>{
entry.isIntersecting && entry.target.classList.add('fft-show');
})
})
fadeFromTop.forEach(el => observerTwo.observe(el));
const fadeFromBottom = document.querySelectorAll('.ffb');
const observerThree = new IntersectionObserver(entries =>{
entries.forEach(entry=>{
entry.isIntersecting && entry.target.classList.add('ffb-show');
})
})
fadeFromBottom.forEach(el => observerThree.observe(el));