-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
57 lines (48 loc) · 1.35 KB
/
main.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
import "./assets";
import { Router } from "@vaadin/router";
import { initRouter } from "./assets/router";
import { lazyLoadVideo } from "./modules/lazyLoadVideo";
import { animarScrollNavbar } from "./modules/animarScrollNavbar";
import { observarAnimacoes } from "./modules/observarAnimacoes";
export let navbar;
let dialog;
let router;
document.addEventListener("DOMContentLoaded", function () {
/* Inicia o roteador */
router = initRouter();
/* Fazer ao carregar a página */
router.ready.then(() => {
lazyLoadVideo()
observarAnimacoes()
});
/* Selecionar navbar */
navbar = document.querySelector("app-navbar");
/* Selecionar dialog de menu */
dialog = document
.querySelector("menu-section")
.shadowRoot.querySelector("dialog");
});
/* Métodos de navegação */
export const nav = {
abrir: function () {
navbar.classList.add("escondido");
dialog.showModal();
},
rolarPara: function (secao) {
/* Primeiro acessa home page, depois rola para a seção */
Router.go("/");
router.ready.then(() => {
document
.querySelector("home-page")
.shadowRoot.querySelector(secao)
.scrollIntoView();
this.fechar();
});
},
fechar: function () {
dialog.close();
},
};
/* Navbar dinâmica ao scroll */
// janela . ao rolar = animarScrollNavbar
window.onscroll = animarScrollNavbar