-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscript.js
50 lines (43 loc) · 1.3 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
// nav toggle functionality
const sideBar = document.querySelector('.sidebar');
const toggleBtn = document.querySelector('.toggle-btn');
const closeBtn = document.querySelector('.times');
const body = document.querySelector('body')
var tl = gsap.timeline();
function showSidebar() {
body.classList.toggle('stop-scrolling');
// sideBar.classList.toggle('show-sidebar');
tl.to(".sidebar", { duration: 0.25, x: 0 })
.to(".sidebar_blue", { duration: 0.25, x: 0 })
.to(".sidebar_green", { duration: 0.25, x: 0 });
// stagger sidebar contents
tl.to(".sidebar .links .link_item", {
opacity: 1,
delay: 1,
y: 0,
stagger: 0.2,
duration: 0.5,
ease: "power2.out"
});
}
function closeSidebar() {
// sideBar.classList.remove('show-sidebar');
// stagger sidebar contents
tl.to(".sidebar .links .link_item", {
opacity: 0,
delay: 1,
y: 20,
stagger: {
each: 0.2,
from: "end"
},
duration: 0.5,
ease: "power2.out"
}, "-=0.5");
tl.to(".sidebar_green", {duration: 0.25, x: "-100%" })
.to(".sidebar_blue", { duration: 0.25, x: "-100%" })
.to(".sidebar", {duration: 0.25, x: "-100%" });
body.classList.toggle('stop-scrolling');
}
toggleBtn.addEventListener('click', showSidebar);
closeBtn.addEventListener('click', closeSidebar);