Jump to content
Search Community

oligsap

Premium
  • Posts

    34
  • Joined

  • Last visited

Community Answers

  1. oligsap's post in GSAP + Lenis smoothscroll - scrolling to anchor breaks tweens was marked as the answer   
    I wanted to add to the solution that when you scroll back up you can't just do .progress(0). You also need to reverse the scrolltriggers array because you may get styles added from timelines tweening values after the previous one. Full code here : 

     
    _this.previousScroll = window.scrollY; window.lenis.scrollTo( href, { immediate: true, onComplete() { let scrollTriggers = ScrollTrigger.getAll(); if (_this.previousScroll > window.scrollY) { scrollTriggers = scrollTriggers.reverse(); } scrollTriggers.forEach((st) => { if (st.animation) { if (window.scrollY > st.start) { st.animation.progress(1); } else { st.animation.progress(0); } } }); _this.previousScroll = window.scrollY; } } );  
×
×
  • Create New...