I've made a react application where I have a component that has a scroll bar at the bottom of it. It's a horizontal scroll bar and I want to get how much the user has scrolled in terms of x position.
When I look it up on internet, such as this question, I usually see results that show how to get the scroll amount on the window.
However I'm looking for the scroll amount on a component that I have created called <Timeline/>
, not the window.
Here is what my component looks like on the console:
When a user scrolls on it, I need to see where exactly the current visible part of it stands so I can make calculations with it.
On a given time only a certain part of the div is visible (As big as the window) and the rest is hidden on both left and right. I want to see, when scrolled, how far the user has scrolled and how much is invisible on the left side of the screen.
How can I get that?