-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
53 lines (43 loc) · 1.75 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
/* MENU SHOW */
const showMenu = (toggleId, navId) =>{
const toggle = document.getElementById(toggleId),
nav = document.getElementById(navId)
if(toggle && nav){
toggle.addEventListener('click', ()=>{
nav.classList.toggle('show')
})
}
}
showMenu('nav-toggle','nav-menu')
/* CLOSE MENU ON LINK CLICK */
// listen on _all_ nav links, including the logo
const navLinks = document.querySelectorAll('.nav__link, .nav__logo');
navLinks.forEach(link => {
link.addEventListener('click', () => {
document.getElementById('nav-menu').classList.remove('show');
});
});
/* NAV LINK ACTIVE STATE */
const currentPage = window.location.pathname.split("/").pop();
const navItems = document.querySelectorAll('.nav__link, .nav__logo');
navItems.forEach(link => {
// If href matches this HTML filename, mark it active
if (link.getAttribute('href') === currentPage) {
link.classList.add('active');
}
});
/*----- ANIMATE -----*/
// OVERLAY
gsap.to(".first", 1.5, {delay: .5, top: "-100%", ease: Expo.easeInOut});
gsap.to(".second", 1.5, {delay: .7, top: "-100%", ease: Expo.easeInOut});
gsap.to(".third", 1.5, {delay: .9, top: "-100%", ease: Expo.easeInOut});
// IMG
gsap.from('.home__img', {opacity: 0, duration: 2, delay: 2, x: 60})
// INFORMATION
gsap.from('.home__information', {opacity: 0, duration: 3, delay: 2.3, y: 25})
gsap.from('.anime-text', {opacity: 0, duration: 3, delay: 2.3, y: 25, ease:'expo.out', stagger: .3})
// NAV ITEM
gsap.from('.nav__logo', {opacity:0, duration: 3, delay: 3.2, y: 25, ease:'expo.out'});
gsap.from('.nav__item', {opacity: 0, duration: 3, delay: 3.2, y: 25, ease:'expo.out', stagger: .2})
// SOCIAL
gsap.from('.home__social-icon', {opacity: 0, duration: 3, delay: 4, y: 25, ease:'expo.out', stagger: .2})