-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
76 lines (56 loc) · 2.09 KB
/
script.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
// Comando para deixar as Box 3d -------------------------------------------------
VanillaTilt.init(document.querySelectorAll(".especialidades_box"), {
max: 25,
speed: 400,
glare: true,
"max-glare": 0.1,
scale: 1.1
})
// Função para abrir o menu mobile ------------------------------------------------
let botao_abrir_menu = document.getElementById('botao_abrir_menu')
let menu_mobile = document.getElementById('menu_mobile')
let overlay_menu = document.getElementById('overlay_menu')
botao_abrir_menu.addEventListener('click', () => {
menu_mobile.classList.add('menu_aberto')
})
menu_mobile.addEventListener('click', () => {
menu_mobile.classList.remove('menu_aberto')
})
overlay_menu.addEventListener('click', () => {
menu_mobile.classList.remove('menu_aberto')
})
// Funções dos links ---------------------------------------------------------------
const menuitens = document.querySelectorAll('.menu_desktop a, .menu_mobile a')
menuitens.forEach(item => {
item.addEventListener('click', ScrollToIdOnClick)
})
function getScrollTopByHref(element) {
const id = element.getAttribute('href');
return document.querySelector(id).offsetTop
}
function ScrollToIdOnClick(event) {
event.preventDefault();
const to = getScrollTopByHref(event.target) - 30;
scrollToPosition(to)
}
function scrollToPosition(to) {
window.scroll({
top: to,
behavior: "smooth"
})
}
const botaorefresh = document.querySelector('#refresh')
botaorefresh.addEventListener('click', () => {
location.reload()
})
// MODO DARK / LIGHT ------------------------------------------- EM BREVE ---------------------------------------------
// let dark = document.getElementById('darkmode')
// let light = document.getElementById('lightmode')
// dark.addEventListener('click', () => {
// dark.classList.toggle('light')
// light.classList.toggle('light')
// })
// light.addEventListener('click', () => {
// dark.classList.toggle('light')
// light.classList.toggle('light')
// })