react-scroll-utilities
Mine, from the first commit to npm: I designed it, built it, tested it and shipped it, and learned how to do each of those along the way.
Why it exists
I was building WordPress pages that needed animations on scroll, writing them by hand in plain JavaScript, and it was really hard. So I thought: I should make a library. And I made it in React, as a challenge, to really understand React. I learned a lot of it by getting it wrong.
The result is a lightweight library of hooks and components: how close an element is to the screen, which way you're scrolling, values and colors that change as you scroll, and shapes that move with it.
Key decisions
-
Math from school
The animations are math. I pulled the logic into small functions built on equations I knew from school, and checked them by hand with notebooks and a graphing calculator before trusting the code.
-
One render, not three
Scroll events fire constantly, so I had to be careful in React not to render more than once per change. One ScrollWatcher at the top of the app reads the scroll and shares it with every hook.
See it work
The hard part
I didn't know TypeScript well, or how to architect an npm library, build TypeScript into JavaScript, or publish and ship it. I learned all of it by failing: there are patch versions that didn't work, published just to see if the package would install. My commits are funny to read now, full of "visual testing" and one that just says "added console.log to know the version".
It took a while, because I was learning by breaking things. It was a lot of fun.
Where it is now
Finished: 16 versions on npm, the last in January 2023. It's close to my heart, and it's the library that got me my job at dotCMS.