Search code examples
javascriptreactjsecmascript-2016npm-package

Is there any way to run asscroll package in react project?


I was searching a few libraries for scroll animations and I found a very good npm package called @ashthornton/asscroll and I wanted to use the same on my react project.

But I am not been able to implement the same. It's not working the way it should. Can someone help me implement the same package in react?

Here, are the links for asscroll package and a Codesandbox for anyone to give it a try.


Solution

  • In order to run it with react you need to initialize ASScroll inside useEffect and also make sure to point out which div element is asscroll-container.

    Since this is a little different in react you need to add to the div asscroll-container="true" (keep in mind that true has to be passed as string).

    I have added this library to my codesandbox as you can see here