From 496ed88fb1f4b5dd7de4b41721daa2ab09b6edf0 Mon Sep 17 00:00:00 2001 From: Daniel Hewes Date: Mon, 20 May 2019 15:51:01 -0700 Subject: [PATCH] Correct height and pass offset to onload function. --- hashy.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hashy.js b/hashy.js index 30ddd34..718b15f 100644 --- a/hashy.js +++ b/hashy.js @@ -29,7 +29,7 @@ if (this.offset_elem.length) { this.offset_elem.each(function () { - offset_height += (jQuery(this).height() - extra_offset); + offset_height += (jQuery(this).outerHeight() - extra_offset); }); } @@ -97,11 +97,12 @@ // Scroll to hash on page load. The browser does this by // default but this will compensate for sticky headers + if (window.location.hash) { jQuery(window).on('load', function () { window.setTimeout(function() { - this.scrollToHash(window.location.hash, true); - }.bind(this), 200); + this.scrollToHash(window.location.hash, true, false, extra_offset); + }.bind(this), 0); }.bind(this)); } }