-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-browser.js
44 lines (34 loc) · 1.29 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
/**
* Implement Gatsby's Browser APIs in this file.
*
* See: https://www.gatsbyjs.com/docs/browser-apis/
*/
// You can delete this file if you're not using it
// // This is where the Framer Motion page transition magic happens
// import React from "react";
// import { AnimatePresence } from "framer-motion";
// export const wrapPageElement = ({element}) => (
// <AnimatePresence exitBeforeEnter>{element}</AnimatePresence>
// )
// // TEMP
// export const shouldUpdateScroll = ({
// routerProps: { location },
// getSavedScrollPosition
// }) => {
// // transition duration from `layout.js` * 1000 to get time in ms
// const TRANSITION_DELAY = 0.3 * 1000 * 2
// // if it's a "normal" route
// if (location.action === "PUSH") {
// window.setTimeout(() => window.scrollTo(0, 0), TRANSITION_DELAY)
// }
// // if we used the browser's forwards or back button
// else {
// // breaking change in shouldUpdateScroll browser API hook:
// // https://github.com/gatsbyjs/gatsby/issues/23842
// // looks like they fixed it in Gatsby v. 2.28.1
// // https://github.com/gatsbyjs/gatsby/pull/27384
// const savedPosition = getSavedScrollPosition(location) || [0, 0]
// window.setTimeout(() => window.scrollTo(...savedPosition), TRANSITION_DELAY)
// }
// return false
// }