From 03bc35afe109f4daa21a15a734cbd8338a1736cf Mon Sep 17 00:00:00 2001 From: Ekaropolus Date: Sat, 19 Jul 2025 18:49:48 -0600 Subject: [PATCH] Javi fixed the scrolll!!!! --- public/home/js/scroll.js | 81 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/public/home/js/scroll.js b/public/home/js/scroll.js index 4e556ce..b324955 100644 --- a/public/home/js/scroll.js +++ b/public/home/js/scroll.js @@ -647,8 +647,85 @@ $(window).on('load',function (){ gsap.set(sections, {xPercent: 0}); -// menu navigation -// super‑basic menu nav test +// scroll.js +// scroll.js + +$(document).on('click', '.js-scroll-link', function(event) { + event.preventDefault(); + + const linkIdx = parseInt($(this).data('link'), 10); + const targetY = linkData[linkIdx]; + const scrollMap = [ 0, 0, 0.25, 0.5, 0.75, 1, 1 ]; + const lastMap = [ 0, 0, 0, 0, 0, 0, 1 ]; + + console.log('▶ CLICK', linkIdx, '→ scroll to', targetY); + + if (blockNavigation || skipMode) { + console.log(' 🚫 navigation locked (blockNavigation=', blockNavigation, 'skipMode=', skipMode, ')'); + return; + } + + // lock UI & fade out + skipMode = true; + $('.header__menu').addClass('blocked'); + gsap.to('.home-page', { duration: 0.4, autoAlpha: 0 }); + console.log(' → fading out'); + + setTimeout(() => { + console.log('▶ ANIMATION START'); + console.log(' st.scroll(', targetY, ')'); + st.scroll(targetY); + + // master timelines + console.log(' tlScroll →', scrollMap[linkIdx]); + console.log(' tlScrollLast →', lastMap[linkIdx]); + tlScroll .progress(scrollMap[linkIdx]); + tlScrollLast.progress(lastMap[linkIdx]); + + // section‐by‐section reset (your original logic unrolled into a loop) + const sectionTGs = [ + tl1, tl11, tl3, tl31, + tl4, tl41, tl5, tl51, + tl6, tl61, tl7 + ]; + sectionTGs.forEach((tl, i) => { + const prog = (i < linkIdx) ? 1 : 0; + console.log(` section[${i}] → ${prog}`); + tl.progress(prog).pause(); + }); + + // title timelines + const titleTGs = [ tlTitle2, tlTitle3, tlTitle4, tlTitle5, tlTitle6, tlTitle7 ]; + titleTGs.forEach((ttl, i) => { + const prog = (i + 1 === linkIdx) ? 1 : 0; + console.log(` title[${i+2}] → ${prog}`); + ttl.progress(prog).pause(); + }); + + // reposition + gsap.set(titles, { y: '100%' }); + gsap.set(titles[linkIdx], { y: '0' }); + gsap.set(sections, { xPercent: -100 * linkIdx, ease: 'none' }, 0); + console.log(' moved panels to', -100 * linkIdx, '%'); + + // menu UI + $('.header__menu li').removeClass('active') + .eq(linkIdx).addClass('active'); + + // fade back in + gsap.to('.home-page', { + duration: 0.5, + autoAlpha: 1, + onComplete() { + console.log('▶ ANIMATION END — unlocking'); + skipMode = false; + $('.header__menu').removeClass('blocked'); + } + }); + }, 500); +}); + +