Hello,
Demo here: https://stackblitz.com/edit/stackblitz-starters-snsg6l?file=app%2Fpage.tsx
I might be using useGSAP incorrectly and trying to use it in reusable child components when it wasn't designed that way however after reading the documentation around scope I'm confused why animations are selecting everything, not just elements within the ref scope
For my website I am trying to create images that scale on scrollTrigger. As I want to use the same animation across every image on the website (and there are hundreds) I am placing the useGSAP hook in the child component for the image rather than in the parent page component so I can simply use the component wherever I want to and it will be rendered with the animation. I eventually want to do the same with text animations as well
However I am finding that when I do this even with a scoped useGSAP in the <Image /> component, if I animate by a scoped selector e.g. ".img" it will animate every ".img" on the page, not just the one contained to the scope. This results in every image animation being triggered at once rather than just the image that was triggered on scroll
Is this just a React thing and I should be doing all animating from the parent page? Just feels like a bit of an anti-pattern in the React world of reusable components
Thanks very much for any help!