I did not find a solution to monitor the appearance and disappearance of the cursor in real time. In any case, there is no direct solution (discarding the variant with the recursive function of checking through the interval).
We can only restrict ourselves to observe the changes that may occur, and in consequence of which they will affect the appearance of the scroll on the page. We catch these actions (or we envisage them in simple cases), and we react with the check function, which does something in connection with this that you need. The implementation is strictly user-friendly and there is hardly any modular solution ever to come in the form of a library.
To view events, you can “hang up” events using the .addEventListner method, and for such complicated ones as adding to the house (or deleting), awarding a class element (and which class), you can monitor MutationObserver . The last is a complicated thing that requires optimization for Firefox and be ready (if you haven’t worked with this before) to spend considerable time on understanding, if you really are not going to just follow the addition of a class to an element.
In the end, I used a bundle: monitor the resize of the window, as well as the MutationObserver for more complex pieces that can occur with elements, and that can affect the appearance of the scroll. You can potestit that I did, if you want, here . When loading, there is no scrolling, after the appearance of the images nothing flies. When you click on a picture, a modal window opens, if you change the height, a scroll will appear, but the picture in the modal window will not leave to the left, and I provided for many other trifles. But I don’t think I can describe a cross-project solution, so I don’t cite any cat.
The answer to the question, in principle, ends, but if you're interested, then an example: the implementation of scroll control on VK. If you open a page on this site without scrolling (for example, bookmarks, they should not be particularly clogged), and start resizing the window in height, the scroll will appear and disappear (down by resize), but the page itself will not move to the left ( adding a scroll) or to the right (if it is missing).
On VKontakte it is implemented clumsily, very. If you get into the element viewer, you will see the body function 'onBodyResize ()', which, apparently, implements all the logic. If we climb and navigate the div wrappers of the site, including the modal window (where the scroll control is also provided), we will see that they always inline new style parameters, such as height and width, when resizing the window. That is, this is always a recalculation of styles, which is very expensive, but it seems that the work of the site is successful in terms of performance, but also a solution.
<script>at the very bottom of thebodytag as in the question and also callconsole.log(get_scroll('Width'))for the call, it will be executed cyclically until the end of the centuries ? It is not true. - VostokSisterssetInterval-