@@ -50,6 +50,7 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
50
50
_scrollEventAttachment ;
51
51
_nativeOffset ;
52
52
_touching = false ;
53
+ _sizeChangeInterval = 0 ;
53
54
54
55
constructor ( props ) {
55
56
super ( props ) ;
@@ -227,7 +228,10 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
227
228
228
229
scroll ( offset : Offset , animated : boolean = true ) {
229
230
return this . scrollTo (
230
- { x : offset . x , y : offset . y + this . _contentOffset . y } ,
231
+ {
232
+ x : offset . x + this . _contentOffset . x ,
233
+ y : offset . y + this . _contentOffset . y ,
234
+ } ,
231
235
animated
232
236
) ;
233
237
}
@@ -283,11 +287,12 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
283
287
}
284
288
285
289
_onKeyboardWillShow = ( evt ) => {
290
+ this . _touching = false ;
286
291
this . props . textInputRefs . every ( ( input ) => {
287
292
if ( idx ( ( ) => input . current . isFocused ( ) ) ) {
288
- input . current . measure ( ( x , y , w , h , l , t ) => {
293
+ input . current . measureInWindow ( ( x , y , w , h , l , t ) => {
289
294
this . _keyboardHeight =
290
- t + h - evt . endCoordinates . screenY + this . props . inputToolBarHeight ;
295
+ - evt . endCoordinates . screenY + this . props . inputToolBarHeight + y + h ;
291
296
this . _keyboardHeight > 0 &&
292
297
this . scroll ( { x : 0 , y : this . _keyboardHeight } ) ;
293
298
} ) ;
@@ -503,11 +508,7 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
503
508
this . props . onSizeChange && this . props . onSizeChange ( { width, height } ) ;
504
509
this . _height = height ;
505
510
this . _width = width ;
506
- if ( ! this . _contentHeight ) return ;
507
- if ( this . _contentHeight < this . _height ) this . _contentHeight = height ;
508
- if ( this . _contentOffset . y > this . _contentHeight - this . _height )
509
- this . scrollToEnd ( ) ;
510
- this . forceUpdate ( ) ;
511
+ this . _startSizeChangeInterval ( ) ;
511
512
}
512
513
} ;
513
514
@@ -521,7 +522,14 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
521
522
this . props . onContentSizeChange ( { width, height } ) ;
522
523
this . _contentHeight = height ;
523
524
this . _contentWidth = width ;
524
- if ( ! this . _height ) return ;
525
+ this . _startSizeChangeInterval ( ) ;
526
+ }
527
+ } ;
528
+
529
+ _startSizeChangeInterval = ( ) => {
530
+ if ( this . _sizeChangeInterval ) clearInterval ( this . _sizeChangeInterval ) ;
531
+ this . _sizeChangeInterval = setInterval ( ( ) => {
532
+ if ( ! this . _height || ! this . _contentHeight ) return ;
525
533
if ( this . _contentHeight < this . _height )
526
534
this . _contentHeight = this . _height ;
527
535
let { x : maxX , y : maxY } = this . _contentOffset ;
@@ -537,7 +545,9 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
537
545
Platform . OS === "android" && this . scrollTo ( { x : maxX , y : maxY } , false ) ;
538
546
}
539
547
this . forceUpdate ( ) ;
540
- }
548
+ clearInterval ( this . _sizeChangeInterval ) ;
549
+ this . _sizeChangeInterval = 0 ;
550
+ } , Platform . select ( { ios : 10 , android : 30 } ) ) ;
541
551
} ;
542
552
543
553
_onTouchBegin = ( e ) => {
0 commit comments