-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
101 lines (82 loc) · 3.06 KB
/
Copy pathmain.js
File metadata and controls
101 lines (82 loc) · 3.06 KB
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
/*=============== SHOW MENU ===============*/
const navMenu = document.getElementById('nav-menu'),
navToggle = document.getElementById('nav-toggle'),
navClose = document.getElementById('nav-close');
// Menu show
if(navToggle){
navToggle.addEventListener('click', () => {
navMenu.classList.add('show-menu')
})
}
// Menu hidden
if(navToggle){
navClose.addEventListener('click', () => {
navMenu.classList.remove('show-menu')
})
}
/*=============== REMOVE MENU MOBILE ===============*/
const navLink = document.querySelectorAll('.nav__link')
const linkAction = () =>{
const navMenu = document.getElementById('nav-menu')
// When we click on each nav__link, we remove the show-menu cl navMenu.classList.remove('show-menu')
navMenu.classList.remove('show-menu');
}
navLink.forEach(n => n.addEventListener('click', linkAction))
/*=============== CHANGE BACKGROUND HEADER ===============*/
const bgHeader = () =>{
const header = document.getElementById('header')
this.scrollY >= 50 ? header.classList.add('bg-header')
: header.classList.remove('bg-header')
}
window.addEventListener('scroll', bgHeader)
bgHeader()
/*=============== SWIPER SERVICES ===============*/
const swiperServices = new Swiper('.services__swiper', {
loop: true,
grapCursor: true,
spaceBetween: 24,
slidesPerView: 'auto',
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
/*=============== SHOW SCROLL UP ===============*/
const scrollUp = () => {
const scrollUp = document.getElementById('scroll-up');
this.scrollY >= 350 ? scrollUp.classList.add('show-scroll') :
scrollUp.classList.remove('show-scroll');
}
window.addEventListener('scroll', scrollUp);
scrollUp()
/*=============== SCROLL SECTIONS ACTIVE LINK ===============*/
const sections = document.querySelectorAll('section[id]')
const scrollActive = () =>{
const scrollDown = window.scrollY
sections.forEach(current =>{
const sectionHeight = current.offsetHeight,
sectionTop = current.offsetTop - 58,
sectionId = current.getAttribute('id'),
sectionsClass = document.querySelector('.nav__menu a[href*=' + sectionId + ']')
if(scrollDown > sectionTop && scrollDown <= sectionTop + sectionHeight){
sectionsClass.classList.add('active-link')
}else{
sectionsClass.classList.remove('active-link')
}
})
}
window.addEventListener('scroll', scrollActive)
scrollActive()
/*=============== SCROLL REVEAL ANIMATION ===============*/
const sr = ScrollReveal({
origin: 'top',
distance: '100px',
duration: 2500,
delay: 400,
reset: true,
})
sr.reveal('.home__content, .services__data, .services__swiper')
sr.reveal('.home__images', {origin:'bottom', delay: 1000})
sr.reveal('.about__images, .contact__img', {origin:'left'})
sr.reveal('.about__data, .contact__data', {origin:'right'})
sr.reveal('.projects__card', {interval: 100})