Hello everyone!
I am new to gsap and its scrolltrigger plugin and now I have my first problem.
I have 2 div elements next to each other.
When you scroll down, the left one gets pinned until it reaches the bottom of the right one.
I calculate the travel distance of the left div with let travelDistance = rightDivHeight-leftDivHeight;
The problem: When the screen gets resized (phone/tablet tilt) the calculation is outdated because the height changes. That throws off the animation. Explained width pictures (see below)
How can I write a function that updates every time the screen size changes? I already tried putting the code in a function and call it with window.addEventListener('resize', updateRightDivHeight); But this didn't update the animation :( Do I have to work on the gsap part? Thank you for helping!