-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e0d2a9
commit a031b1a
Showing
2 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/*=============== SHOW MENU ===============*/ | ||
const navMenu = document.getElementById('nav-menu'), | ||
navToggle = document.getElementById('nav-toggle'), | ||
navClose = document.getElementById('nav-close') | ||
|
||
/*===== MENU SHOW =====*/ | ||
/* Validate if constant exists */ | ||
if(navToggle){ | ||
navToggle.addEventListener('click', () =>{ | ||
navMenu.classList.add('show-menu') | ||
}) | ||
} | ||
|
||
/*===== MENU HIDDEN =====*/ | ||
/* Validate if constant exists */ | ||
if(navClose){ | ||
navClose.addEventListener('click', () =>{ | ||
navMenu.classList.remove('show-menu') | ||
}) | ||
} | ||
|
||
|
||
/*=============== REMOVE MENU MOBILE ===============*/ | ||
const navLink = document.querySelectorAll('.nav__link') | ||
|
||
function linkAction(){ | ||
const navMenu = document.getElementById('nav-menu') | ||
// When we click on each nav__link, we remove the show-menu class | ||
navMenu.classList.remove('show-menu') | ||
} | ||
navLink.forEach(n => n.addEventListener('click', linkAction)) | ||
|
||
/*=============== ADD BLUR TO HEADER ===============*/ | ||
const blurHeader = () =>{ | ||
const header = document.getElementById('header') | ||
// When the scroll is greater than 100 viewport height, add the blur-header class to the header tag | ||
this.scrollY >= 50 ? header.classList.add('blur-header') | ||
: header.classList.remove('blur-header') | ||
} | ||
window.addEventListener('scroll', blurHeader) | ||
|
||
/*=============== SHOW SCROLL UP ===============*/ | ||
|
||
const scrollUp =() =>{ | ||
const scrollUp = document.getElementById('scroll-up') | ||
this.scrollY >= 350 ? scrollUp.classList.add('show-scroll') | ||
: scrollUp.classList.remove('show-scroll') | ||
} | ||
window.addEventListener('scroll', scrollUp) | ||
|
||
|
||
|
||
/*=============== SCROLL SECTIONS ACTIVE LINK ===============*/ | ||
|
||
const sections = document.querySelectorAll('section[id]') | ||
|
||
const scrollActive = () =>{ | ||
const scrollDown = window.scrollY | ||
|
||
sections.forEach(current =>{ | ||
const sectionHeight = current.offsetHeight, | ||
sectionTop = current.offsetTop - 58, | ||
sectionId = current.getAttribute('id'), | ||
sectionsClass = document.querySelector('.nav__menu a[href*=' + sectionId + ']') | ||
|
||
if(scrollDown > sectionTop && scrollDown <= sectionTop + sectionHeight){ | ||
sectionsClass.classList.add('active-link') | ||
}else{ | ||
sectionsClass.classList.remove('active-link') | ||
} | ||
}) | ||
} | ||
window.addEventListener('scroll', scrollActive) | ||
|
||
/*=============== SCROLL REVEAL ANIMATION ===============*/ | ||
const sr = ScrollReveal({ | ||
origin: 'top', | ||
distance: '60px', | ||
duration: 3000, | ||
delay: 400, | ||
//reset: true // Animation repeat | ||
|
||
}) | ||
|
||
sr.reveal(`.home__data, .explore__data, .explore__user, .footer__container`) | ||
sr.reveal(`.home__card`, {delay: 600, distance: '100px',interval: 100}) | ||
sr.reveal(`.about__data, .join__image`, {origin: 'right'}) | ||
sr.reveal(`.about__image, .join__data`, {origin: 'left'}) | ||
sr.reveal(`.popular__card`, {interval: '200'}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.