A
A
Alex Krynytskyi2021-01-15 17:14:51
React
Alex Krynytskyi, 2021-01-15 17:14:51

How to write scroll tracking for a component in ReactJS?

I want to set css animation of soft appearance when scrolling.
how to set wiretapping scroll?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Sugonyaev, 2021-01-15
@NEOmanceR

As I understand it, the problem is precisely that it is necessary to listen to the scroll not of window, but of a specific block?
Then:
1. We get a link to a specific react element - https://reactjs.org/docs/refs-and-the-dom.html
2. Then you can simply listen to the scroll event through native js - https://learn.javascript. en/size-and-scroll
Just don't forget to remove the listener when you unmount the component.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question