|
| 1 | +/*===== MENU SHOW =====*/ |
| 2 | +const showMenu = (toggleId, navId) =>{ |
| 3 | + const toggle = document.getElementById(toggleId), |
| 4 | + nav = document.getElementById(navId) |
| 5 | + |
| 6 | + if(toggle && nav){ |
| 7 | + toggle.addEventListener('click', ()=>{ |
| 8 | + nav.classList.toggle('show') |
| 9 | + }) |
| 10 | + } |
| 11 | +} |
| 12 | +showMenu('nav-toggle','nav-menu') |
| 13 | + |
| 14 | +/*==================== REMOVE MENU MOBILE ====================*/ |
| 15 | +const navLink = document.querySelectorAll('.nav__link') |
| 16 | + |
| 17 | +function linkAction(){ |
| 18 | + const navMenu = document.getElementById('nav-menu') |
| 19 | + // When we click on each nav__link, we remove the show-menu class |
| 20 | + navMenu.classList.remove('show') |
| 21 | +} |
| 22 | +navLink.forEach(n => n.addEventListener('click', linkAction)) |
| 23 | + |
| 24 | +/*==================== SCROLL SECTIONS ACTIVE LINK ====================*/ |
| 25 | +const sections = document.querySelectorAll('section[id]') |
| 26 | + |
| 27 | +const scrollActive = () =>{ |
| 28 | + const scrollDown = window.scrollY |
| 29 | + |
| 30 | + sections.forEach(current =>{ |
| 31 | + const sectionHeight = current.offsetHeight, |
| 32 | + sectionTop = current.offsetTop - 58, |
| 33 | + sectionId = current.getAttribute('id'), |
| 34 | + sectionsClass = document.querySelector('.nav__menu a[href*=' + sectionId + ']') |
| 35 | + |
| 36 | + if(scrollDown > sectionTop && scrollDown <= sectionTop + sectionHeight){ |
| 37 | + sectionsClass.classList.add('active-link') |
| 38 | + }else{ |
| 39 | + sectionsClass.classList.remove('active-link') |
| 40 | + } |
| 41 | + }) |
| 42 | +} |
| 43 | +window.addEventListener('scroll', scrollActive) |
| 44 | + |
| 45 | +/*===== SCROLL REVEAL ANIMATION =====*/ |
| 46 | +const sr = ScrollReveal({ |
| 47 | + origin: 'top', |
| 48 | + distance: '60px', |
| 49 | + duration: 2000, |
| 50 | + delay: 200, |
| 51 | +// reset: true |
| 52 | +}); |
| 53 | + |
| 54 | +sr.reveal('.home__data, .about__img, .skills__subtitle, .skills__text',{}); |
| 55 | +sr.reveal('.home__img, .about__subtitle, .about__text, .skills__img',{delay: 400}); |
| 56 | +sr.reveal('.home__social-icon',{ interval: 200}); |
| 57 | +sr.reveal('.skills__data, .work__img, .contact__input',{interval: 200}); |
0 commit comments