forked from brohlson/gatsby-plugin-anchor-links
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgatsby-browser.js
33 lines (26 loc) · 901 Bytes
/
gatsby-browser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.onRouteUpdate = void 0;
var _utils = require("./utils");
var onRouteUpdate = function onRouteUpdate(_ref, _ref2) {
var location = _ref.location;
var _ref2$offset = _ref2.offset,
offset = _ref2$offset === void 0 ? 0 : _ref2$offset,
_ref2$duration = _ref2.duration,
duration = _ref2$duration === void 0 ? 1000 : _ref2$duration;
var windowHash;
if (_utils.isBrowser) {
window.gatsby_scroll_offset = offset;
window.gatsby_scroll_duration = duration;
windowHash = window.gatsby_scroll_hash;
}
window.setTimeout(function () {
windowHash ? (0, _utils.scroller)(windowHash, offset) : (0, _utils.checkHash)(location, offset);
if (_utils.isBrowser && windowHash) {
window.gatsby_scroll_hash = undefined;
}
}, 50);
};
exports.onRouteUpdate = onRouteUpdate;