Get an element's distance from the top of the Document
/**
* Get an element's distance from the top of the Document.
* @private
* @param {Node} elem The element
* @return {Number} Distance from the top in pixels
*/
var getOffsetTop = function ( elem ) {
var location = 0;
if (elem.offsetParent) {
do {
location += elem.offsetTop;
elem = elem.offsetParent;
} while (elem);
} else {
location = elem.offsetTop;
}
location = location - headerHeight - settings.offset;
return location >= 0 ? location : 0;
};