Hi There,
I've posted previously which was super helpful and I am just wondering if I could have some assistance with how this behaves when I port it to React. I have been sifting through the documentation on and off for months now and just can't find the solution.
Basically I have a landing page, and as you scroll down, the nav fades in at the top of the second section, and then pins to the top once it hits the top of the screen (https://codepen.io/akapowl/pen/poLPyBj is the intended behaviour).
I have created a variable called `textSize` that convert a css viewport width to pixels as I couldnt get the timeline to work using vw. As a result of this, I believe it is throwing off some calculations when the screens are resized/orientation is changed. To ensure that the timeline recalculates on resize, I added props that trigger a useEffect when the screen is resized. I'm using useRef to point to the same timeline, and am killing it before re-creating a new timeline. I have replicated this in CodeSandbox https://codesandbox.io/s/youthful-ganguly-c2qfr2 (or https://c2qfr2.csb.app/ for site only)
A way to replicate this is to open the site, scroll down a bit, then open inspect element and resize the screen. You will notice that in a lot of cases, the nav either disappears completely, or just renders wrong. Or even just simply opening the site on an iPad/iPhone and changing the orientation of the device breaks the nav. I also noticed that this is more likely to happen if you have scrolled down the page before you re-size.
What am I doing wrong? Any guidance would be greatly appreciated.
Best,
Kane