HTMLify
main.js
Views: 70 | Author: vinay5ain
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 54 55 56 57 58 | /*=============== CHANGE BACKGROUND HEADER ===============*/ const scrollHeader = () => { const header = document.getElementById('header') this.scrollY >= 50 ? header.classList.add('scroll-header') : header.classList.remove('scroll-header') } window.addEventListener('scroll', scrollHeader) /*=============== 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 section = document.querySelectorAll('section[id]') const scrollActive = () =>{ const scrollY = window.pageYOffset section.forEach(current =>{ const sectionHeight = current.offsetHeight, sectionTop = current.offsetTop - 58, sectionId = current.getAttribute('id'), sectionClass = document.querySelector('.nav__menu a[href*=' + sectionId + ']') if(scrollY > sectionTop && scrollY <= sectionTop + sectionHeight){ sectionClass.classList.add('active-link') }else{ sectionClass.classList.remove('active-link') } }) } window.addEventListener('scroll', scrollActive) /*=============== SCROLL REVEAL ANIMATION ===============*/ const sr = ScrollReveal({ origin: 'top', distance: '60px', duration: 2500, delay: 400, reset: true // Anomation repeat }) sr.reveal(`.home__data, .products__data, .steps__content, .footer__container`) sr.reveal(`.home__img`, {origin: 'bottom'}) sr.reveal(`.products__card`, {interval: 100}) sr.reveal(`.about__img, .testimonial__img`, {origin: 'right'}) sr.reveal(`.about__data, .testimonial__data`, {origin: 'left'}) |