When using a nested scroll you'll probably get a wrong result. I worked around the issue by comparing the boundary rectangles of the regular & scroll elements.