jsonkao / react-scrollama

Simple scrollytelling with the IntersectionObserver in React.
https://jsonkao.github.io/react-scrollama
MIT License
388 stars 30 forks source link

Providing Types for TypeScript? #98

Open alinoob opened 1 year ago

alinoob commented 1 year ago

Would it be possible to publish types for TypeScript?

chasedawson commented 1 year ago

@alinoob I also think type definitions would be helpful! You may have already found a workaround, but I wanted to include one I found here too for future people looking to use this repo.

I found this workaround from this article. Basically, create a decs.d.ts file and the line declare module "react-scrollama". Then, you just have to make sure the include field in your tsconfig.json will pick up decs.d.ts.

I'm still pretty new to working with TypeScript, so there may be better workarounds, but this did the trick for me!

alinoob commented 1 year ago

I actually switched to the gsap library which is pretty neat aswell. But thanks for your reply.

0xMohamed commented 7 months ago

I actually switched to the gsap library which is pretty neat aswell. But thanks for your reply.

Is gsap doing the same doing scrollama?

jsonkao commented 7 months ago

I dont think so. I just read https://gsap.com/docs/v3/Plugins/ScrollTrigger/#how-does-scrolltrigger-work-is-it-just-like-intersectionobserver

React Scrollama is pretty simple, it's just a wrapper around IntersectionObserver, and it's meant to serve use cases that aren't that complex (e.g. a simple scrollytelling article). GSAP seems to be doing much more complex stuff, and also uses (debounced) scroll events rather than IntersectionObserver. And it seems to be used for fairly involved interactions/animations.

0xMohamed commented 7 months ago

but sometimes in scrollama with intersection Observer does not detect all steps successfully when scrolling fast or when there are complex state changes.