Jump to content
Search Community

Navigation between multiple horizontal scrolling sections

chardin test
Moderator Tag

Recommended Posts

Hi, 

 

I would like to be able to navigate between two scrolling sections. Right now it works, but how can I be sure to always go to the beginning of the section? Also, I want the animation to be instantaneous. 

 

Also, there is a weird stutter sometimes once I have navigated to the section. Not sure what is causing that. 

 

See the Pen PoVPmrB by chethardin (@chethardin) on CodePen

Link to comment
Share on other sites

  • chardin changed the title to Navigation between multiple horizontal scrolling sections

Hi,

 

This should do it:

document.querySelectorAll("[data-trigger]").forEach((item, index) => {
  item.addEventListener("click", (event) => {
    event.preventDefault();
    const st = stInstances[index];
    gsap.set(window, { scrollTo: { y: st.start } });
  });
});

Hopefully this helps.

Happy Tweening!

Link to comment
Share on other sites

Hi,

 

That has to do with the fact that you have a scrub value different than true, that translate into the animation progress catching up during that time (1 second in your case). if you change that to just scrub: true it works but you don't get that scrub during a period of time effect.

 

This seems to work the way you expect:

document.querySelectorAll("[data-trigger]").forEach((item, index) => {
  item.addEventListener("click", (event) => {
    event.preventDefault();
    const st = stInstances[index];
    gsap.set(window, { scrollTo: { y: st.start } });
    st.animation.progress(0);
  });
});

Hopefully this helps.

Happy Tweening!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...