-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-browser.js
45 lines (37 loc) · 1.2 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
/**
* Implement Gatsby's Browser APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/browser-apis/
*/
// You can delete this file if you're not using it
// export const onClientEntry = () => {
// // IntersectionObserver polyfill for gatsby-background-image (Safari, IE)
// if (typeof window.IntersectionObserver === `undefined`) {
// import(`intersection-observer`)
// console.log(`# IntersectionObserver is polyfilled!`)
// }
// }
require('typeface-ibm-plex-sans');
require('typeface-ibm-plex-serif')
require('typeface-ibm-plex-mono')
export const onServiceWorkerUpdateReady = () => {
const answer = window.confirm(
`This application has been updated. ` +
`Reload to display the latest version?`
)
if (answer === true) {
window.location.reload()
}
}
export const shouldUpdateScroll = ({
routerProps: { location },
getSavedScrollPosition,
pathname
}) => {
const currentPosition = getSavedScrollPosition(pathname);
console.log('current position',currentPosition)
// console.log(getSavedScrollPosition(location));
const queriedPosition = getSavedScrollPosition({ pathname: `/about` })
window.scrollTo(...(currentPosition || [0, 0]))
return true
}