|
1 | | -document.addEventListener('DOMContentLoaded', () => { |
2 | | - const textWrapper = document.querySelector('.hero-title'); |
| 1 | +import { createTimeline, stagger, animate } from 'https://cdn.jsdelivr.net/npm/animejs/+esm'; |
3 | 2 |
|
4 | | - if (textWrapper) { |
5 | | - textWrapper.innerHTML = textWrapper.textContent.replace(/\S/g, "<span class='letter'>$&</span>"); |
6 | | - anime.timeline({loop: false}) |
7 | | - .add({ |
8 | | - targets: '.hero-title .letter', |
9 | | - scale: [4, 1], |
10 | | - opacity: [0, 1], |
11 | | - translateZ: 0, |
12 | | - easing: "easeOutExpo", |
13 | | - duration: 950, |
14 | | - delay: (el, i) => 70 * i |
15 | | - }); |
16 | | - } |
| 3 | +particlesJS.load('particles-js', 'particlesjs-config.json', function() { |
| 4 | + console.log('callback - particles.js config loaded'); |
| 5 | +}) |
| 6 | + |
| 7 | +const textWrapper = document.querySelector('.hero-title'); |
| 8 | +if (textWrapper) { |
| 9 | + textWrapper.innerHTML = textWrapper.textContent.replace(/\S/g, "<span class='letter'>$&</span>"); |
| 10 | + |
| 11 | + const tl = createTimeline({loop: false, direction: 'alternate'}); |
| 12 | + tl.add('.hero-title .letter', { |
| 13 | + opacity: [0, 1], |
| 14 | + translateY: [-200, 0], |
| 15 | + easing: 'easeOutExpo', |
| 16 | + duration: 1400, |
| 17 | + delay: stagger(70), |
| 18 | + }); |
| 19 | +} |
| 20 | + |
| 21 | +if (document.querySelector('.project-grid')) { |
| 22 | + animate('.project-card', { |
| 23 | + translateY: [50, 0], |
| 24 | + easing: 'easeOutExpo', |
| 25 | + opacity: [0, 1], |
| 26 | + delay: stagger(100), |
| 27 | + }); |
| 28 | +} |
| 29 | + |
| 30 | +const observer = new IntersectionObserver((entries) => { |
| 31 | + entries.forEach(entry => { |
| 32 | + if (entry.isIntersecting) { |
| 33 | + entry.target.classList.add('visible'); |
| 34 | + } |
| 35 | + }); |
| 36 | +}, { |
| 37 | + threshold: 0.1 |
17 | 38 | }); |
| 39 | + |
| 40 | +const revealElements = document.querySelectorAll('.reveal-section'); |
| 41 | +revealElements.forEach(el => observer.observe(el)); |
0 commit comments