This repository was archived by the owner on Sep 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from TylerBarnes/prevent-scroll-jumping-on-save
Prevent scroll jumping on save during development by adding a wrapper…
- Loading branch information
Showing
8 changed files
with
2,418 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// this function is used to set the outerwrapper height to keep the page from jumping up on save during development. | ||
export default function pageMinHeight({ node, updateContext }) { | ||
const minHeight = node.offsetHeight; | ||
if (minHeight > 0) { | ||
sessionStorage.setItem("wrapperMinHeight", node.offsetHeight); | ||
updateContext && updateContext({ wrapperMinHeight: node.offsetHeight }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
const React = require("react"); | ||
const TransitionHandler = require("./components/TransitionHandler").default; | ||
const InternalProvider = require("./context/InternalProvider").default; | ||
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"); | ||
return ( | ||
<InternalProvider> | ||
<TransitionHandler {...props}>{element}</TransitionHandler> | ||
<Consumer> | ||
{({ wrapperMinHeight }) => ( | ||
<div | ||
style={{ | ||
position: "relative", | ||
zIndex: 0, | ||
minHeight: wrapperMinHeight | ||
? `${wrapperMinHeight}px` | ||
: `${minHeight}px` | ||
}} | ||
> | ||
<TransitionHandler {...props}>{element}</TransitionHandler> | ||
</div> | ||
)} | ||
</Consumer> | ||
</InternalProvider> | ||
); | ||
}; |
Oops, something went wrong.