Jump to content
Search Community

Hermes Grau

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by Hermes Grau

  1. Hi @steph72. The thing is that the whole sections movement is just an animation (a timeline). The page is forced to have a height just to provoke the scroll necessary to connect this timeline animation to the page scroll, but the sections are not really scrolling. From there, I'm afraid that any function or animation related to the section's positions should be called inside this timeline at the point that you need.

    You could even create different timelines for the inner sections animations, and add() to the main timeline at the right position.

    Does it help?

  2. Hi!

    Sure, I've added a nav.

    See the Pen qBoLWeW by hermesgrau (@hermesgrau) on CodePen

     

    I have used ScrollTo plugin and a helper function to scroll to a timeline label.

    function labelToScroll(timeline, label) {
      let st = timeline.scrollTrigger;
      return st.start + (st.end - st.start) * (timeline.labels[label] / timeline.duration());
    }

     

    Helper function found here: 

     

    Then you can do something like this:

    gsap.to(window, {
      duration: .6,
      scrollTo: labelToScroll(tl, 'your-label'),
    })

     

    You could add a data-scroll-to to the nav links with the label you want to target.

     

    • Like 4
  3. Thank you Jack!
    I didn't notice that.

     

    So, I've tested it and for now my solution could be:

    snap: (value) => {
      const snapPoints = [0, 0.5, 1];
      const proximity = 0.1;
    
      for (let i = 0; i < snapPoints.length; i++) {
        if (value > snapPoints[i] - proximity && value < snapPoints[i] + proximity) {
          return snapPoints[i];
        }
      }
    }

    Now I just need to find the way to calculate the snap points dynamically from the sections/labels positions.

     

    Working codepen:

    See the Pen xxWQNWM by hermesgrau (@hermesgrau) on CodePen

     

    Anyway, as Cassie said, could be great to have this as a built in option.
    For whole page sections I feel more natural to let the user stop whenever he/she wants, and fix the position just on the edges.

     

    Thank u both!

     

    • Like 2
×
×
  • Create New...