forked from binary-com/binary-static
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhackathon.js
More file actions
25 lines (22 loc) · 898 Bytes
/
hackathon.js
File metadata and controls
25 lines (22 loc) · 898 Bytes
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
// Handler when the DOM is fully loaded
document.addEventListener('DOMContentLoaded', () => {
toggleMobileMenu();
const navbar = document.getElementsByClassName('navbar')[0];
// Scroll to section
document.addEventListener('click', (e) => {
if (e.target.classList.contains('page-scroll')) {
const target = e.target.getAttribute('href').substr(1);
const offset = target === 'page-top' ? 55 : 0;
const navbarHeight = checkWidth();
const el_target = document.getElementById(target);
const to = el_target ? el_target.offsetTop - navbarHeight - offset : '';
scrollTo(to, 500);
if (navbar.classList.contains('expand')) {
navbar.classList.remove('expand');
}
e.preventDefault();
}
});
window.onresize = checkWidth;
commonOnload();
});