Fixed the offset calculation in when scrolling
Therefore added a new function getAncestorOffset()