getEndLocation = function (anchor, headerHeight, offset, clip) {
		var location = 0;
		if (anchor.offsetParent) {
			do {
				location += anchor.offsetTop;
				anchor = anchor.offsetParent;
			} while (anchor);
		}
		location = Math.max(location - headerHeight - offset, 0);
		if (clip) {
			location = Math.min(location, getDocumentHeight() - window.innerHeight);
		}
			return location;
	}
Calculate how far to scroll
Clip support added by robjtede - https://github.com/cferdinandi/smooth-scroll/issues/405
@param {Element} anchor       The anchor element to scroll to
@param {Number}  headerHeight Height of a fixed header, if any
@param {Number}  offset       Number of pixels by which to offset scroll
@param {Boolean} clip         If true, adjust scroll distance to prevent abrupt stops near the bottom of the page
@returns {Number}