Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #15 from TylerBarnes/prevent-scroll-jumping-on-save
Browse files Browse the repository at this point in the history
check for session storage existance before trying to use it
  • Loading branch information
TylerBarnes committed Nov 23, 2018
2 parents d8ca0c5 + 3524721 commit 898849e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gatsby-plugin-transition-link",
"version": "1.3.0",
"version": "1.3.1",
"description": "A link component for page transitions in gatsby.",
"repository": "https://github.com/TylerBarnes/gatsby-plugin-transition-link",
"homepage": "https://gatsby-plugin-transition-link.netlify.com/",
Expand Down
7 changes: 5 additions & 2 deletions src/wrap-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ const Consumer = require("./context/createTransitionContext").Consumer;

// eslint-disable-next-line react/prop-types,react/display-name
module.exports = ({ element, props }) => {
const minHeight = sessionStorage.getItem("wrapperMinHeight");
const sessionMinHeight =
typeof sessionStorage !== "undefined"
? sessionStorage.getItem("wrapperMinHeight")
: false;
return (
<InternalProvider>
<Consumer>
Expand All @@ -16,7 +19,7 @@ module.exports = ({ element, props }) => {
zIndex: 0,
minHeight: wrapperMinHeight
? `${wrapperMinHeight}px`
: `${minHeight}px`
: `${!!sessionMinHeight ? sessionMinHeight + "px" : false}`
}}
>
<TransitionHandler {...props}>{element}</TransitionHandler>
Expand Down

0 comments on commit 898849e

Please sign in to comment.