Using ScrollReveal.js with React Hooks

Henrique Ramos - Jan 19 '21 - - Dev Community

Today, I decided to improve my website by adding scroll reveal to it. For that, I chose jlmakes' ScrollReveal.js which solved my problem in a snap, the biggest problem was integrating it with React (Turns out, it was also a piece of cake).

The code

ScrollReveal.js provides a constructor ScrollReveal() that returns its instance. The method reveal() is responsible for registering the target element with ScrollReveal, it has a target argument (which can be a CSS Selector, a DOM Node, or an Array of Nodes) and an options argument which allows customizing the reveal behavior. That being said, we can use useRef hook to connect the React Node to ScrollReveal:

. . . . . . . . . . . . . . . . . . .
Terabox Video Player