@@ -96,7 +96,11 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
9696 refreshHeader : Refresh ,
9797 loadingFooter : Loading
9898 } = this . props ;
99- const wStyle = StyleSheet . flatten ( [ styles . wrapperStyle , style , { transform : inverted ? [ { scaleY : - 1 } ] : [ ] } ] ) ;
99+ const wStyle = StyleSheet . flatten ( [
100+ styles . wrapperStyle ,
101+ style ,
102+ { transform : inverted ? [ { scaleY : - 1 } ] : [ ] }
103+ ] ) ;
100104 const elements = (
101105 < SpringScrollViewNative
102106 { ...this . props }
@@ -113,7 +117,7 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
113117 onNativeContentOffsetExtract = { this . _nativeOffset }
114118 >
115119 < SpringScrollContentViewNative
116- style = { StyleSheet . flatten ( [ { minHeight : "100%" } , this . props . contentStyle ] ) }
120+ style = { this . props . contentStyle }
117121 collapsable = { false }
118122 onLayout = { this . _onContentLayoutChange }
119123 >
@@ -146,7 +150,11 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
146150 return (
147151 onRefresh && (
148152 < Animated . View style = { this . _getRefreshHeaderStyle ( ) } >
149- < Refresh ref = { ref => ( this . _refreshHeader = ref ) } offset = { this . _offsetY } maxHeight = { Refresh . height } />
153+ < Refresh
154+ ref = { ref => ( this . _refreshHeader = ref ) }
155+ offset = { this . _offsetY }
156+ maxHeight = { Refresh . height }
157+ />
150158 </ Animated . View >
151159 )
152160 ) ;
@@ -177,7 +185,9 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
177185 if ( ! measured ) return null ;
178186 return (
179187 showsVerticalScrollIndicator &&
180- this . _contentHeight > this . _height && < Animated . View style = { this . _getVerticalIndicatorStyle ( ) } />
188+ this . _contentHeight > this . _height && (
189+ < Animated . View style = { this . _getVerticalIndicatorStyle ( ) } />
190+ )
181191 ) ;
182192 }
183193
@@ -188,7 +198,9 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
188198 if ( ! measured ) return null ;
189199 return (
190200 showsHorizontalScrollIndicator &&
191- this . _contentWidth > this . _width && < Animated . View style = { this . _getHorizontalIndicatorStyle ( ) } />
201+ this . _contentWidth > this . _width && (
202+ < Animated . View style = { this . _getHorizontalIndicatorStyle ( ) } />
203+ )
192204 ) ;
193205 }
194206
@@ -215,9 +227,18 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
215227
216228 scrollTo ( offset : Offset , animated : boolean = true ) {
217229 if ( Platform . OS === "ios" ) {
218- NativeModules . SpringScrollView . scrollTo ( findNodeHandle ( this . _scrollView ) , offset . x , offset . y , animated ) ;
230+ NativeModules . SpringScrollView . scrollTo (
231+ findNodeHandle ( this . _scrollView ) ,
232+ offset . x ,
233+ offset . y ,
234+ animated
235+ ) ;
219236 } else if ( Platform . OS === "android" ) {
220- UIManager . dispatchViewManagerCommand ( findNodeHandle ( this . _scrollView ) , 10002 , [ offset . x , offset . y , animated ] ) ;
237+ UIManager . dispatchViewManagerCommand ( findNodeHandle ( this . _scrollView ) , 10002 , [
238+ offset . x ,
239+ offset . y ,
240+ animated
241+ ] ) ;
221242 }
222243 return new Promise ( ( resolve , reject ) => {
223244 if ( animated ) setTimeout ( resolve , 500 ) ;
@@ -317,7 +338,7 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
317338 }
318339
319340 _getVerticalIndicatorStyle ( ) {
320- const indicatorHeight = ( this . _height / this . _contentHeight ) * this . _height ;
341+ const indicatorHeight = this . _height / this . _contentHeight * this . _height ;
321342 return {
322343 position : "absolute" ,
323344 top : 0 ,
@@ -336,7 +357,7 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
336357 }
337358
338359 _getHorizontalIndicatorStyle ( ) {
339- const indicatorWidth = ( this . _width / this . _contentWidth ) * this . _width ;
360+ const indicatorWidth = this . _width / this . _contentWidth * this . _width ;
340361 return {
341362 position : "absolute" ,
342363 bottom : 2 ,
@@ -380,7 +401,8 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
380401 console . warn (
381402 "unsupported value: '" ,
382403 style ,
383- "' in SpringScrollView, " + "select one in 'topping','stickyScrollView','stickyContent' please"
404+ "' in SpringScrollView, " +
405+ "select one in 'topping','stickyScrollView','stickyContent' please"
384406 ) ;
385407 }
386408 if ( this . props . inverted ) transform . push ( { scaleY : - 1 } ) ;
@@ -421,14 +443,15 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
421443 console . warn (
422444 "unsupported value: '" ,
423445 style ,
424- "' in SpringScrollView, " + "select one in 'bottoming','stickyScrollView','stickyContent' please"
446+ "' in SpringScrollView, " +
447+ "select one in 'bottoming','stickyScrollView','stickyContent' please"
425448 ) ;
426449 }
427450 if ( this . props . inverted ) transform . push ( { scaleY : - 1 } ) ;
428451 return {
429452 position : "absolute" ,
430453 right : 0 ,
431- bottom : - fHeight ,
454+ top : this . _height > this . _contentHeight ? this . _height : this . _contentHeight ,
432455 height : fHeight ,
433456 left : 0 ,
434457 transform
@@ -445,6 +468,7 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
445468 this . _height = height ;
446469 this . _width = width ;
447470 if ( ! this . _contentHeight ) return ;
471+ if ( this . _contentHeight < this . _height ) this . _contentHeight = height ;
448472 if ( this . _offsetYValue > this . _contentHeight - this . _height ) this . scrollToEnd ( ) ;
449473 this . forceUpdate ( ) ;
450474 }
@@ -460,13 +484,15 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
460484 this . _contentHeight = height ;
461485 this . _contentWidth = width ;
462486 if ( ! this . _height ) return ;
487+ if ( this . _contentHeight < this . _height ) this . _contentHeight = this . _height ;
463488 if ( this . _offsetYValue > this . _contentHeight - this . _height ) this . scrollToEnd ( false ) ;
464489 this . forceUpdate ( ) ;
465490 }
466491 } ;
467492
468493 _onTouchBegin = ( ) => {
469- if ( TextInputState . currentlyFocusedField ( ) ) TextInputState . blurTextInput ( TextInputState . currentlyFocusedField ( ) ) ;
494+ if ( TextInputState . currentlyFocusedField ( ) )
495+ TextInputState . blurTextInput ( TextInputState . currentlyFocusedField ( ) ) ;
470496 this . _indicatorAnimation && this . _indicatorAnimation . stop ( ) ;
471497 this . _indicatorOpacity . setValue ( 1 ) ;
472498 this . props . tapToHideKeyboard && Keyboard . dismiss ( ) ;
@@ -499,4 +525,5 @@ const SpringScrollViewNative = Animated.createAnimatedComponent(
499525 requireNativeComponent ( "SpringScrollView" , SpringScrollView )
500526) ;
501527
502- const SpringScrollContentViewNative = Platform . OS === "ios" ? requireNativeComponent ( "SpringScrollContentView" ) : View ;
528+ const SpringScrollContentViewNative =
529+ Platform . OS === "ios" ? requireNativeComponent ( "SpringScrollContentView" ) : View ;
0 commit comments