This repository was archived by the owner on Sep 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +2418
-2
lines changed Expand file tree Collapse file tree 8 files changed +2418
-2
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " gatsby-plugin-transition-link" ,
3
- "version" : " 1.2.5 " ,
3
+ "version" : " 1.3.0 " ,
4
4
"description" : " A link component for page transitions in gatsby." ,
5
5
"repository" : " https://github.com/TylerBarnes/gatsby-plugin-transition-link" ,
6
6
"homepage" : " https://gatsby-plugin-transition-link.netlify.com/" ,
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ export default class PaintDrip extends Component {
22
22
rgb = color ? convert . keyword . rgb ( color ) : rgb ;
23
23
24
24
canvas . style . zIndex = 10000 ;
25
+ canvas . style . top = 0 ;
25
26
canvas . style . position = "fixed" ;
26
27
27
28
let vw = ( canvas . width = window . innerWidth ) ;
Original file line number Diff line number Diff line change @@ -9,9 +9,35 @@ import { getMs } from "../utils/secondsMs";
9
9
import { onEnter } from "../functions/onEnter" ;
10
10
import { onExit } from "../functions/onExit" ;
11
11
import { LayoutComponent as Layout } from "./Layout" ;
12
+ import pageMinHeight from "../functions/pageMinHeight" ;
12
13
13
14
const DelayedTransition = delayTransitionRender ( Transition ) ;
14
15
export default class TransitionHandler extends Component {
16
+ constructor ( props ) {
17
+ super ( props ) ;
18
+
19
+ this . wrapper = React . createRef ( ) ;
20
+ this . updatePageMinHeight = this . updatePageMinHeight . bind ( this ) ;
21
+ }
22
+ componentDidMount ( ) {
23
+ this . updatePageMinHeight ( ) ;
24
+ window . addEventListener ( "resize" , this . updatePageMinHeight ) ;
25
+ }
26
+
27
+ componentWillUnmount ( ) {
28
+ window . removeEventListener ( "resize" , this . updatePageMinHeight ) ;
29
+ }
30
+
31
+ updatePageMinHeight ( ) {
32
+ setTimeout (
33
+ ( ) =>
34
+ pageMinHeight ( {
35
+ node : this . wrapper
36
+ } ) ,
37
+ 1
38
+ ) ;
39
+ }
40
+
15
41
render ( ) {
16
42
const { props } = this ;
17
43
const { children } = props ;
@@ -30,6 +56,7 @@ export default class TransitionHandler extends Component {
30
56
exitProps,
31
57
transitionIdHistory,
32
58
inTransition,
59
+ updateContext,
33
60
e
34
61
} ) => {
35
62
return (
@@ -53,6 +80,8 @@ export default class TransitionHandler extends Component {
53
80
entryProps,
54
81
exitProps,
55
82
pathname,
83
+ updateContext,
84
+ pageMinHeight,
56
85
e
57
86
} )
58
87
}
@@ -99,6 +128,7 @@ export default class TransitionHandler extends Component {
99
128
100
129
return (
101
130
< div
131
+ ref = { n => ( this . wrapper = n ) }
102
132
className = "tl-wrapper"
103
133
style = { {
104
134
position : "absolute" ,
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ class InternalProvider extends Component {
6
6
state = {
7
7
inTransition : false ,
8
8
transitionIdHistory : [ ] ,
9
+ wrapperMinHeight : false ,
9
10
// event
10
11
e : false ,
11
12
// exit
Original file line number Diff line number Diff line change @@ -5,8 +5,12 @@ const onEnter = ({
5
5
entryProps,
6
6
exitProps,
7
7
pathname,
8
+ pageMinHeight,
9
+ updateContext,
8
10
e
9
11
} ) => {
12
+ pageMinHeight ( { node, updateContext } ) ;
13
+
10
14
if ( inTransition ) {
11
15
window . scrollTo ( 0 , 0 ) ;
12
16
} else {
Original file line number Diff line number Diff line change
1
+ // this function is used to set the outerwrapper height to keep the page from jumping up on save during development.
2
+ export default function pageMinHeight ( { node, updateContext } ) {
3
+ const minHeight = node . offsetHeight ;
4
+ if ( minHeight > 0 ) {
5
+ sessionStorage . setItem ( "wrapperMinHeight" , node . offsetHeight ) ;
6
+ updateContext && updateContext ( { wrapperMinHeight : node . offsetHeight } ) ;
7
+ }
8
+ }
Original file line number Diff line number Diff line change 1
1
const React = require ( "react" ) ;
2
2
const TransitionHandler = require ( "./components/TransitionHandler" ) . default ;
3
3
const InternalProvider = require ( "./context/InternalProvider" ) . default ;
4
+ const Consumer = require ( "./context/createTransitionContext" ) . Consumer ;
4
5
5
6
// eslint-disable-next-line react/prop-types,react/display-name
6
7
module . exports = ( { element, props } ) => {
8
+ const minHeight = sessionStorage . getItem ( "wrapperMinHeight" ) ;
7
9
return (
8
10
< InternalProvider >
9
- < TransitionHandler { ...props } > { element } </ TransitionHandler >
11
+ < Consumer >
12
+ { ( { wrapperMinHeight } ) => (
13
+ < div
14
+ style = { {
15
+ position : "relative" ,
16
+ zIndex : 0 ,
17
+ minHeight : wrapperMinHeight
18
+ ? `${ wrapperMinHeight } px`
19
+ : `${ minHeight } px`
20
+ } }
21
+ >
22
+ < TransitionHandler { ...props } > { element } </ TransitionHandler >
23
+ </ div >
24
+ ) }
25
+ </ Consumer >
10
26
</ InternalProvider >
11
27
) ;
12
28
} ;
You can’t perform that action at this time.
0 commit comments