-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
47 lines (39 loc) · 1.48 KB
/
index.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
// preloader
const preloaderTL = gsap.timeline();
preloaderTL.to('#logo', {yPercent: -20, opacity: 0, delay: 2})
preloaderTL.to('.preloader', {transform: 'scaleY(0)', transformOrigin: 'top', delay: '-=1'})
// open all social links in new tab
let socialLinks = document.querySelectorAll('.social-links--box a');
socialLinks.forEach(link => {
link.target = '_blank';
});
// custom cursor
const cursor = document.querySelector('.cursor');
window.onmousemove = (e) => {
cursor.setAttribute('style', `top: ${e.pageY}px; left: ${e.pageX}px; z-index: 2;`)
}
// navigation
const tl = gsap.timeline({paused:true, reversed: true});
tl.to('.box', {height: '100vh', duration: .5, transformOrigin: 'bottom', stagger: .3})
tl.to('.mobile-logo', {opacity: '1'})
tl.to('.nav-main__content', {opacity: '1', visibility: 'visible', yPercent: -5, duration: .5, transformOrigin: 'bottom', stagger: .3})
const navIcon = document.querySelector('.nav-icon');
navIcon.onclick = function() {
if (tl.reversed()) {
this.classList.add('nav-anim')
tl.play()
document.body.classList.add('noScroll');
} else {
this.classList.remove('nav-anim')
tl.reverse()
document.body.classList.remove('noScroll');
}
}
const allLinks = document.querySelectorAll('.list__item a');
allLinks.forEach(link => {
link.addEventListener('click', () => {
document.body.classList.remove('noScroll');
tl.reverse()
navIcon.classList.remove('nav-anim')
})
})