I am currently having a function which scrolls the table once triggered via onClick. The scroll moves from top to bottom in repeat cycle.
The function is as below:
dom-element: ref.current attached to table
target: total height of the table in px
duration: scroll speed
scrollForTopBottom(dom-element, target, duration)
Now, if I give duration = 2000 then the table will reach bottom in 2 seconds but I want it to go slow. I tried setting duration = target(px)*20 but that would create problem when target (scroll height) is too long and will scroll very slowly. Same for target (scroll height) when its not too long.
I am guessing I have to set the formula of duration inversely proportional to target (scroll height) ?
I have no idea how to do it. I hope I didn't make the question complex.