1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-22 17:23:22 +01:00
portfolio/gatsby-browser.js
Matthias Kretschmann b315f5bbb0
Migrate to Framer Motion (#656)
* migrate to Framer Motion

* animation tweaks

* faster animations

* handle reduced motion

* handle SSR
2021-09-11 21:37:38 +02:00

38 lines
1.1 KiB
JavaScript

import wrapPageElementWithLayout from './src/helpers/wrapPageElement'
// Global styles
import './src/styles/global.css'
// IntersectionObserver polyfill for gatsby-image (Safari, IE)
if (typeof window !== 'undefined' && !window.IntersectionObserver) {
import('intersection-observer')
}
// Layout with Page Transitions
export const wrapPageElement = wrapPageElementWithLayout
export const shouldUpdateScroll = ({
routerProps: { location },
getSavedScrollPosition
}) => {
if (location.action === 'PUSH') {
window.setTimeout(() => window.scrollTo(0, 0), 200)
} else {
const savedPosition = getSavedScrollPosition(location)
window.setTimeout(() => window.scrollTo(...(savedPosition || [0, 0])), 200)
}
return false
}
// Display a message when a service worker updates
// https://www.gatsbyjs.org/docs/add-offline-support-with-a-service-worker/#displaying-a-message-when-a-service-worker-updates
export const onServiceWorkerUpdateReady = () => {
const answer = window.confirm(
'This application has been updated. ' +
'Reload to display the latest version?'
)
if (answer === true) {
window.location.reload()
}
}