a more precise way to check a possibility of scrolling

Previous method was not precise and was cause an errors in some cases