-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
42 lines (38 loc) · 921 Bytes
/
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
import './style.css';
import 'swiper';
// import Swiper from 'swiper';
/**
* Selector helper.
*
* Can be used similarly to JQuery.
*
* @param selector
* @returns HTML or throw error
*/
const $ = selector => {
const el = document.querySelector(selector);
if (!el) throw Error(`Element cannot be found with ${selector} selector.`);
return el;
};
/**
* TODO
*/
window.addEventListener('scroll', () => {
const $header = $('#header');
if (window.screenY >= 15) $header.classList.add('activated');
else $header.classList.remove('activated');
});
/**
* Select #menu-toggle-icon
*
* @type {*|jQuery|HTMLElement}
*/
const $menuToggleIcon = $('#menu-toggle-icon');
/**
* Toggle activated class on #menu click
*/
$menuToggleIcon.addEventListener('click', () => {
const $menu = $('#menu');
$menu.classList.toggle('activated');
$menuToggleIcon.classList.toggle('activated');
});