-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
42 lines (33 loc) · 953 Bytes
/
app.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
const burger = document.querySelector('.burger');
const nav = document.querySelector('.nav-links');
const navLinks = document.querySelectorAll('.nav-links li')
let width = document.body.offsetWidth
let navClosed = true // used to toggle the animation
const burgerClick = () => {
if (width <= 768) {
navClosed = !navClosed
navClosed ? timeline.reverse() : timeline.play();
} else {
navClosed = true
// navClosed = !navClosed
}
}
burger.addEventListener('click', burgerClick)
nav.addEventListener('click', burgerClick)
const timeline = gsap.timeline(
{ defaults: { duration: 1}
})
timeline
.to('.nav-links', {
x: 0, ease: 'power',
})
.to('.nav-links li', {
opacity: 1,
}, '<.5').pause() // animation is paused by default
window.addEventListener('resize', () => {
width = document.body.offsetWidth
console.log(width)
if (width >= 769) {
location.reload()
}
})