|
| 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 | + navMenu.classList.remove('show') |
| 20 | +} |
| 21 | +navLink.forEach(n => n.addEventListener('click', linkAction)) |
| 22 | + |
| 23 | +/*===== SCROLL SECTIONS ACTIVE LINK =====*/ |
| 24 | +const sections = document.querySelectorAll('section[id]') |
| 25 | + |
| 26 | +window.addEventListener('scroll', scrollActive) |
| 27 | + |
| 28 | +function scrollActive(){ |
| 29 | + const scrollY = window.pageYOffset |
| 30 | + |
| 31 | + sections.forEach(current =>{ |
| 32 | + const sectionHeight = current.offsetHeight |
| 33 | + const sectionTop = current.offsetTop - 50; |
| 34 | + sectionId = current.getAttribute('id') |
| 35 | + |
| 36 | + if(scrollY > sectionTop && scrollY <= sectionTop + sectionHeight){ |
| 37 | + document.querySelector('.nav__menu a[href*=' + sectionId + ']').classList.add('active') |
| 38 | + }else{ |
| 39 | + document.querySelector('.nav__menu a[href*=' + sectionId + ']').classList.remove('active') |
| 40 | + } |
| 41 | + }) |
| 42 | +} |
| 43 | + |
| 44 | +/*===== SCROLL REVEAL ANIMATION =====*/ |
| 45 | +const sr = ScrollReveal({ |
| 46 | + origin: 'top', |
| 47 | + distance: '80px', |
| 48 | + duration: 2000, |
| 49 | + reset: true |
| 50 | +}) |
| 51 | + |
| 52 | +/*SCROLL HOME*/ |
| 53 | +sr.reveal('.home__title', {}) |
| 54 | +sr.reveal('.home__scroll', {delay: 200}) |
| 55 | +sr.reveal('.home__img', {origin:'right', delay: 400}) |
| 56 | + |
| 57 | +/*SCROLL ABOUT*/ |
| 58 | +sr.reveal('.about__img', {delay: 500}) |
| 59 | +sr.reveal('.about__subtitle', {delay: 300}) |
| 60 | +sr.reveal('.about__profession', {delay: 400}) |
| 61 | +sr.reveal('.about__text', {delay: 500}) |
| 62 | +sr.reveal('.about__social-icon', {delay: 600, interval: 200}) |
| 63 | + |
| 64 | +/*SCROLL SKILLS*/ |
| 65 | +sr.reveal('.skills__subtitle', {}) |
| 66 | +sr.reveal('.skills__name', {distance: '20px', delay: 50, interval: 100}) |
| 67 | +sr.reveal('.skills__img', {delay: 400}) |
| 68 | + |
| 69 | +/*SCROLL PORTFOLIO*/ |
| 70 | +sr.reveal('.portfolio__img', {interval: 200}) |
| 71 | + |
| 72 | +/*SCROLL CONTACT*/ |
| 73 | +sr.reveal('.contact__subtitle', {}) |
| 74 | +sr.reveal('.contact__text', {interval: 200}) |
| 75 | +sr.reveal('.contact__input', {delay: 400}) |
| 76 | +sr.reveal('.contact__button', {delay: 600}) |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
0 commit comments