I need a way to automatically find the maximum bottom value of scrollTop, of the div id "#box".
Something like this: How to get maximum document scrolltop value
but just in a div, not the whole browser window. How can I do this?
To get or set the scroll position of an element, you follow these steps: First, select the element using the selecting methods such as querySelector() . Second, access the scroll position of the element via the scrollLeft and scrollTop properties.
scrollTop()Returns: Number. Description: Get the current vertical position of the scroll bar for the first element in the set of matched elements or set the vertical position of the scroll bar for every matched element.
ng-scrolltop demo: angular component that monitors current Y position in a long page or element then if scrolled down enough, shows up a clickable, unobtrusive icon that scrolls to top smoothly.
You can check if window. scrollY (the number of pixels the window has scrolled vertically) is equal to 0 . If you want to check if the window has been scrolled to its leftermost, you can check if window. scrollX (the number of pixels the window has scrolled horizontally) is equal to 0 .
here you go:
var trueDivHeight = $('.someclass')[0].scrollHeight; var divHeight = $('.someclass').height(); var scrollLeft = trueDivHeight - divHeight; alert(scrollLeft);
Simplified
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With