Jump to content
Search Community

Ihatetomatoes last won the day on August 8 2016

Ihatetomatoes had the most liked content!

Ihatetomatoes

Business
  • Posts

    145
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by Ihatetomatoes

  1. Hi, I am on my mobile so can't really write much code but I belive you just need an array of refs for this to work. Currently you are only animating the last item because that what the anim.current is.

     

    Checkout this example on how to create an array or refs in React and use them with ScrollTrigger.

     

    https://ihatetomatoes.net/react-and-greensock-tutorial-for-beginners/#5-how-to-create-an-array-of-refs

     

    Let me know if that helped.

     

    • Like 3
  2. Thanks @ZachSaucier, this is a great solution and works fine with absolute positioned boxed with fixed size.

     

    I have updated my demo where the box size and also the spacing between elements is more dynamic.

     

    .box {
      width: 12.5vw;
      height: 12.5vw;
      line-height: 12.5vw;
      font-size: 10vw;
      margin-bottom: 200px
    }

    Everything works fine on the initial page load.

    1. navigation links are scrolling to the right offset 
    2. the height of the body and #scroll-container is set on page load
    3. the height is correctly recalculated on window resize

    See the Pen zYrJREM by ihatetomatoes (@ihatetomatoes) on CodePen

     

    The challenge

    • scroll to the right offset after window resize

    The Issue

    • for each link we are creating the initial eventListener to scroll the window to scrollTo: targetRect.top
    • on page resize targetRect.top remains the same

    I know we are going into the scrolljacking rabbit hole here, but I am trying to update the code to make this happen. Any insights are very welcome.

  3. @greensock one more question. I see that you have made the initial tween of the container a variable let scroll = gsap.to(container, {...})

     

    How does this change the way ScrollTrigger manages the container tween? In other words why do you need to store it in a variable?

  4. @GreenSock, yep that is it, thanks Jack. 

     

    Is this your recommended approach for smooth scrolling with navigation?

     

    I like this approach. The default body scrollbar instead of the scrolljacking.

     

    It is great to see that so much can be achieved purely with the GSAP suite of plugins.

  5. Hi everyone, I have been playing with the new ScrollTrigger and smooth scrolling (without scrolljacking).

     

    Blake's Codepen was very useful.

     

    See the Pen zYrJREM by ihatetomatoes (@ihatetomatoes) on CodePen

     

    I have made a modification where there is a navigation that scrolls to the right box. Everything works when you click on the navigation links but the window scrollbar is out of sync.

     

    See the Pen zYrJREM by ihatetomatoes (@ihatetomatoes) on CodePen

     

    I have tried a few things such as updating the documentElement.scrollTop when the tween is completed but it is still out of sync.

     

    Does anyone know what am I missing?

     

    Cheers

    Petr

  6. Thanks Rodrigo for the code examples. I know most people here prefer the class approach for the more readable code, but I think it's useful to give people a clear way how to use GSAP tween and timeline with both class and hooks approach.

     

    If you think there is something missing or not clear enough in this guide please let me know.

     

    https://ihatetomatoes.net/react-and-greensock-tutorial-for-beginners/

     

    I will create more guides for React + GSAP and class approach would definitely be one of them.

    • Like 2
  7. If you manage to isolate the issue into a reduced CodePen demo, I am sure we can point out what is wrong with your code.

     

    At the moment it looks like too many plugins are affecting the layout of your page and it could be any of the other plugins causing the issue.

     

    Try the delay as you suggested, but I doubt it will help.

     

    Sorry I couldn't be more helpful.

     

    And you English is perfect, no need to apologize :)

    • Like 1
×
×
  • Create New...