@@ -24,7 +24,7 @@ export default class Headroom extends Component {
24
24
style : PropTypes . object ,
25
25
calcHeightOnResize : PropTypes . bool ,
26
26
tag : PropTypes . string ,
27
- } ;
27
+ }
28
28
29
29
static defaultProps = {
30
30
parent : ( ) => window ,
@@ -39,9 +39,9 @@ export default class Headroom extends Component {
39
39
pinStart : 0 ,
40
40
calcHeightOnResize : true ,
41
41
tag : 'div' ,
42
- } ;
42
+ }
43
43
44
- static getDerivedStateFromProps ( props , state ) {
44
+ static getDerivedStateFromProps ( props , state ) {
45
45
if ( props . disable && state . state !== 'unfixed' ) {
46
46
return {
47
47
translateY : 0 ,
@@ -54,7 +54,7 @@ export default class Headroom extends Component {
54
54
return null
55
55
}
56
56
57
- constructor ( props ) {
57
+ constructor ( props ) {
58
58
super ( props )
59
59
// Class variables.
60
60
this . currentScrollY = 0
@@ -69,7 +69,7 @@ export default class Headroom extends Component {
69
69
}
70
70
}
71
71
72
- componentDidMount ( ) {
72
+ componentDidMount ( ) {
73
73
this . setHeightOffset ( )
74
74
75
75
this . eventListenerOptions = supportsPassiveEvents ( )
@@ -97,14 +97,14 @@ export default class Headroom extends Component {
97
97
}
98
98
}
99
99
100
- shouldComponentUpdate ( nextProps , nextState ) {
100
+ shouldComponentUpdate ( nextProps , nextState ) {
101
101
return (
102
102
! shallowequal ( this . props , nextProps ) ||
103
103
! shallowequal ( this . state , nextState )
104
104
)
105
105
}
106
106
107
- componentDidUpdate ( prevProps , prevState ) {
107
+ componentDidUpdate ( prevProps , prevState ) {
108
108
// If children have changed, remeasure height.
109
109
if ( prevProps . children !== this . props . children ) {
110
110
this . setHeightOffset ( )
@@ -151,7 +151,7 @@ export default class Headroom extends Component {
151
151
}
152
152
}
153
153
154
- componentWillUnmount ( ) {
154
+ componentWillUnmount ( ) {
155
155
if ( this . props . parent ( ) ) {
156
156
this . props
157
157
. parent ( )
@@ -190,55 +190,55 @@ export default class Headroom extends Component {
190
190
} else if ( this . props . parent ( ) . scrollTop !== undefined ) {
191
191
return this . props . parent ( ) . scrollTop
192
192
} else {
193
- return ( document . documentElement || document . body . parentNode || document . body ) . scrollTop
193
+ return (
194
+ document . documentElement ||
195
+ document . body . parentNode ||
196
+ document . body
197
+ ) . scrollTop
194
198
}
195
199
}
196
200
197
- getViewportHeight = ( ) => (
198
- window . innerHeight
199
- || document . documentElement . clientHeight
200
- || document . body . clientHeight
201
- )
201
+ getViewportHeight = ( ) =>
202
+ window . innerHeight ||
203
+ document . documentElement . clientHeight ||
204
+ document . body . clientHeight
202
205
203
206
getDocumentHeight = ( ) => {
204
207
const body = document . body
205
208
const documentElement = document . documentElement
206
209
207
210
return Math . max (
208
- body . scrollHeight , documentElement . scrollHeight ,
209
- body . offsetHeight , documentElement . offsetHeight ,
210
- body . clientHeight , documentElement . clientHeight
211
+ body . scrollHeight ,
212
+ documentElement . scrollHeight ,
213
+ body . offsetHeight ,
214
+ documentElement . offsetHeight ,
215
+ body . clientHeight ,
216
+ documentElement . clientHeight
211
217
)
212
218
}
213
219
214
- getElementPhysicalHeight = elm => Math . max (
215
- elm . offsetHeight ,
216
- elm . clientHeight
217
- )
220
+ getElementPhysicalHeight = elm => Math . max ( elm . offsetHeight , elm . clientHeight )
218
221
219
- getElementHeight = elm => Math . max (
220
- elm . scrollHeight ,
221
- elm . offsetHeight ,
222
- elm . clientHeight ,
223
- )
222
+ getElementHeight = elm =>
223
+ Math . max ( elm . scrollHeight , elm . offsetHeight , elm . clientHeight )
224
224
225
225
getScrollerPhysicalHeight = ( ) => {
226
226
const parent = this . props . parent ( )
227
227
228
- return ( parent === window || parent === document . body )
228
+ return parent === window || parent === document . body
229
229
? this . getViewportHeight ( )
230
230
: this . getElementPhysicalHeight ( parent )
231
231
}
232
232
233
233
getScrollerHeight = ( ) => {
234
234
const parent = this . props . parent ( )
235
235
236
- return ( parent === window || parent === document . body )
236
+ return parent === window || parent === document . body
237
237
? this . getDocumentHeight ( )
238
238
: this . getElementHeight ( parent )
239
239
}
240
240
241
- isOutOfBound = ( currentScrollY ) => {
241
+ isOutOfBound = currentScrollY => {
242
242
const pastTop = currentScrollY < 0
243
243
244
244
const scrollerPhysicalHeight = this . getScrollerPhysicalHeight ( )
@@ -333,7 +333,7 @@ export default class Headroom extends Component {
333
333
this . scrollTicking = false
334
334
}
335
335
336
- render ( ) {
336
+ render ( ) {
337
337
const { className : userClassName , tag : Tag , ...divProps } = this . props
338
338
delete divProps . onUnpin
339
339
delete divProps . onPin
@@ -350,7 +350,10 @@ export default class Headroom extends Component {
350
350
const { style, wrapperStyle, ...rest } = divProps
351
351
352
352
let innerStyle = {
353
- position : this . props . disable || this . state . state === 'unfixed' ? 'relative' : 'fixed' ,
353
+ position :
354
+ this . props . disable || this . state . state === 'unfixed'
355
+ ? 'relative'
356
+ : 'fixed' ,
354
357
top : 0 ,
355
358
left : 0 ,
356
359
right : 0 ,
0 commit comments