How to hide scroll bar for inactivity?
- The onscroll event is used to disable the scroll bar.
- The onscroll event acts as soon as the page is scrolled. So, the setTimeout() method is used to provide a delay to hide the scroll bar, so that we are able to scroll down first.
- The time can be adjusted according to our requirements.
- onmousemove event is used to enable scrolling as soon as the mouse pointer is moved. onclick event is used to enable scrolling as soon as the user clicks. onmousewheel event is used to enable scrolling as soon as the page is scrolled down. Thus, these events help us to enable scrolling when the page becomes active again.
Example 2: This example hides the scrollbar on the image.
Output: The main disadvantage of hiding the scroll bar for inactivity is that as soon as the scrollbar hides, the contents of the body ‘jump’ to fill up the space that was occupied by the scrollbar. Thus, it does not appear very appealing to the user.