-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
62 lines (54 loc) · 1.41 KB
/
scripts.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
window.addEventListener('scroll', onScroll)
onScroll()
function onScroll() {
navScroll()
backTopShow()
menuActiveSection(home)
menuActiveSection(servicos)
menuActiveSection(about)
}
function navScroll() {
if (scrollY > 0) {
navbar.classList.add("scroll")
}else {
navbar.classList.remove("scroll")
}
}
function backTopShow () {
if (scrollY > 500) {
backTop.classList.add("show")
}else {
backTop.classList.remove("show")
}
}
function openMenu() {
document.body.classList.add('menu-expanded')
}
function closeMenu() {
document.body.classList.remove("menu-expanded")
}
function menuActiveSection (section) {
const targetLine = scrollY + innerHeight / 2
const sectionTop = section.offsetTop
const sectionHeight = section.offsetHeight
const sectionPassedTarget = targetLine >= sectionTop
const sectionEndAt = sectionTop + sectionHeight
const sectionEndTargetLine = sectionEndAt <= targetLine
const sectionlimite = sectionPassedTarget && !sectionEndTargetLine
const menuElement = document.querySelector(`.menu a[href*=${section.getAttribute('id')}]`)
menuElement.classList.remove('active')
if(sectionlimite) {
menuElement.classList.add('active')
}
}
ScrollReveal({
origin: 'top',
distance: '30px',
duration: 700,
}).reveal(`#home,
#home img,
#home .stats,
#servicos,
#servicos header,
#servicos card,
#about,`);