R
R
real22102020-06-04 14:05:52
JavaScript
real2210, 2020-06-04 14:05:52

Ref scrollTop = scrollHeight why is scrollTop not equal to scrollHeight?

Dear, I'm trying to scroll the block to the very bottom after loading the data.
I use useRef and this construction

ref.current.scrollTop = ref.current.scrollHeight;

The block is scrolled, but not to the end
Values ​​are:
scrollHeihgt:
When mounting - 444
After receiving data - 1884

scrollTop:
After assigning - 1440

from here I see that for some reason scrollHeight is minus clientHeight

What's the trouble?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lynn "Coffee Man", 2020-06-04
@Lynn

So what's the trouble?
Can't scroll past block boundaries, so scrollTop is cast to the nearest valid value.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question