1
1
import React , { Component } from 'react'
2
- import { Animated , Dimensions , ScrollView , View , ViewPropTypes , Image } from 'react-native'
2
+ import { Animated , Dimensions , View , ViewPropTypes } from 'react-native'
3
3
4
4
const styles = require ( './styles' )
5
5
@@ -13,7 +13,7 @@ const pivotPoint = (a, b) => a - b
13
13
14
14
const renderEmpty = ( ) => < View />
15
15
16
- const noRender = ( ) => < View style = { { display : 'none' } } />
16
+ const noRender = ( ) => < View style = { { display : 'none' } } />
17
17
18
18
// Override `toJSON` of interpolated value because of
19
19
// an error when serializing style on view inside inspector.
@@ -63,7 +63,7 @@ class ParallaxScrollView extends Component {
63
63
viewWidth : window . width
64
64
}
65
65
this . scrollY = new Animated . Value ( 0 )
66
- this . _footerComponent = { setNativeProps ( ) { } } // Initial stub
66
+ this . _footerComponent = { setNativeProps ( ) { } } // Initial stub
67
67
this . _footerHeight = 0
68
68
}
69
69
@@ -181,7 +181,7 @@ class ParallaxScrollView extends Component {
181
181
parallaxHeaderHeight,
182
182
stickyHeaderHeight,
183
183
onChangeHeaderVisibility,
184
- onScroll : prevOnScroll = e => { }
184
+ onScroll : prevOnScroll = ( ) => { }
185
185
} = this . props
186
186
this . props . scrollEvent && this . props . scrollEvent ( e )
187
187
const p = pivotPoint ( parallaxHeaderHeight , stickyHeaderHeight )
@@ -243,10 +243,10 @@ class ParallaxScrollView extends Component {
243
243
width : viewWidth ,
244
244
opacity : fadeOutBackground
245
245
? interpolate ( scrollY , {
246
- inputRange : [ 0 , p * ( 1 / 2 ) , p * ( 3 / 4 ) , p ] ,
247
- outputRange : [ 1 , 0.3 , 0.1 , 0 ] ,
248
- extrapolate : 'clamp'
249
- } )
246
+ inputRange : [ 0 , p * ( 1 / 2 ) , p * ( 3 / 4 ) , p ] ,
247
+ outputRange : [ 1 , 0.3 , 0.1 , 0 ] ,
248
+ extrapolate : 'clamp'
249
+ } )
250
250
: 1 ,
251
251
transform : [
252
252
{
@@ -292,10 +292,10 @@ class ParallaxScrollView extends Component {
292
292
height : parallaxHeaderHeight ,
293
293
opacity : fadeOutForeground
294
294
? interpolate ( scrollY , {
295
- inputRange : [ 0 , p * ( 1 / 2 ) , p * ( 3 / 4 ) , p ] ,
296
- outputRange : [ 1 , 0.3 , 0.1 , 0 ] ,
297
- extrapolate : 'clamp'
298
- } )
295
+ inputRange : [ 0 , p * ( 1 / 2 ) , p * ( 3 / 4 ) , p ] ,
296
+ outputRange : [ 1 , 0.3 , 0.1 , 0 ] ,
297
+ extrapolate : 'clamp'
298
+ } )
299
299
: 1
300
300
}
301
301
] }
@@ -319,7 +319,7 @@ class ParallaxScrollView extends Component {
319
319
320
320
this . containerHeight = this . state . viewHeight ;
321
321
322
- children . forEach ( ( item ) => {
322
+ React . Children . forEach ( children , ( item ) => {
323
323
if ( item && Object . keys ( item ) . length != 0 ) {
324
324
this . containerHeight = 0 ;
325
325
}
@@ -385,32 +385,32 @@ class ParallaxScrollView extends Component {
385
385
>
386
386
{ renderStickyHeader
387
387
? < Animated . View
388
+ style = { {
389
+ backgroundColor : backgroundColor ,
390
+ height : stickyHeaderHeight ,
391
+ opacity : interpolate ( scrollY , {
392
+ inputRange : [ 0 , p ] ,
393
+ outputRange : [ 0 , 1 ] ,
394
+ extrapolate : 'clamp'
395
+ } )
396
+ } }
397
+ >
398
+ < Animated . View
388
399
style = { {
389
- backgroundColor : backgroundColor ,
390
- height : stickyHeaderHeight ,
391
- opacity : interpolate ( scrollY , {
392
- inputRange : [ 0 , p ] ,
393
- outputRange : [ 0 , 1 ] ,
394
- extrapolate : 'clamp'
395
- } )
400
+ transform : [
401
+ {
402
+ translateY : interpolate ( scrollY , {
403
+ inputRange : [ 0 , p ] ,
404
+ outputRange : [ stickyHeaderHeight , 0 ] ,
405
+ extrapolate : 'clamp'
406
+ } )
407
+ }
408
+ ]
396
409
} }
397
410
>
398
- < Animated . View
399
- style = { {
400
- transform : [
401
- {
402
- translateY : interpolate ( scrollY , {
403
- inputRange : [ 0 , p ] ,
404
- outputRange : [ stickyHeaderHeight , 0 ] ,
405
- extrapolate : 'clamp'
406
- } )
407
- }
408
- ]
409
- } }
410
- >
411
- { renderStickyHeader ( ) }
412
- </ Animated . View >
411
+ { renderStickyHeader ( ) }
413
412
</ Animated . View >
413
+ </ Animated . View >
414
414
: null }
415
415
{ renderFixedHeader && renderFixedHeader ( ) }
416
416
</ View >
@@ -428,7 +428,7 @@ ParallaxScrollView.defaultProps = {
428
428
backgroundColor : '#000' ,
429
429
contentBackgroundColor : '#fff' ,
430
430
fadeOutForeground : true ,
431
- onChangeHeaderVisibility : ( ) => { } ,
431
+ onChangeHeaderVisibility : ( ) => { } ,
432
432
renderScrollComponent : props => < Animated . ScrollView { ...props } /> ,
433
433
renderBackground : renderEmpty ,
434
434
renderContentBackground : noRender ,
0 commit comments