SoFunction
Updated on 2025-02-28

Simple example of judgment based on scroll bar position

Examples are as follows:

//Get the scroll bar's distance from the top positionfunction getScrollTop() {
 var scrollTop = 0;
 if ( && ) {
  scrollTop = ;
 } else if () {
  scrollTop = ;
 }
 return scrollTop;
}
//Get the height of the current visual rangefunction getClientHeight() {
 var clientHeight = 0;
 if ( && ) {
  clientHeight = (, );
 } else {
  clientHeight = (, );
 }
 return clientHeight;
}
//Get the full height of the documentfunction getScrollHeight() {
 return (, );
}
//Judge whether the scroll bar reaches the bottomgetScrollTop() + getClientHeight() == getScrollHeight()

The above simple example based on the scroll bar position judgment is all the content I share with you. I hope you can give you a reference and I hope you can support me more.