writing
you probably don't need GSAP
Jun 14, 2023

This is probably part of a larger discussion, maybe best suited for stealing.rocks, but here it goes: you probably don't need GSAP for your (svelte) project.

GSAP is a great library, one that still has valid use cases in 2023. However, most modern sites don't require much more than scroll animations via GSAP's infamous ScrollTrigger module. The title could be renamed to "you probably don't need scrolltrigger", but it's cleaner otherwise.

<svelte:window bind:scrollY={y}> works in most cases to access scroll position. You can then listen to changes of this y value by creating a reactive statement: $: onScrollFunction(y), which will automatically fire when y changes.

You can then just grab your target div's position from the top of the page and add that to the scrollY to get your "start" value. You could alternatively use intersection observer from Fractils to set the start when the element is visible.