``` if (element.scrollLeft) coordinates.left = coordinates.left - element.scrollLeft; if (element.scrollHeight) coordinates.top = coordinates.top - element.scrollTop; ``` right before returning the result, solves the issue.