@@ -44,14 +44,19 @@ class ScrollableTabs extends Component {
4444 this . state . x . addListener ( ( e ) => {
4545 if ( e . value % ( this . space + tabNavItemWidth ) === 0 ) {
4646 let index = Math . abs ( e . value / ( this . space + tabNavItemWidth ) ) ;
47- typeof this . props . onPageChangedAndAnimateEnd === 'function' && this . props . onPageChangedAndAnimateEnd ( index , this . _isScrolling ( ) ) ;
47+ typeof this . props . onPageChangedAndAnimateEnd === 'function' && this . props . onPageChangedAndAnimateEnd ( index , this . isScrolling ( ) ) ;
4848 }
4949 } ) ;
5050 this . _navs = { } ;
5151 this . shouldComponentUpdate = PureRenderMixin . shouldComponentUpdate . bind ( this ) ;
5252 }
5353
5454
55+ isScrolling ( ) {
56+ return ( ) => this . _scrolling ;
57+ }
58+
59+
5560 _updateNavScale ( offset ) {
5661 const space = this . space + this . props . tabNavItemWidth ;
5762 this . props . tabs . forEach ( ( item , index ) => {
@@ -67,7 +72,7 @@ class ScrollableTabs extends Component {
6772 scale = ( max - offset ) / space ;
6873 }
6974
70- if ( offset == center ) {
75+ if ( offset === center ) {
7176 scale = 1 ;
7277 }
7378 this . _navs [ index ] . setNativeProps ( {
@@ -92,12 +97,9 @@ class ScrollableTabs extends Component {
9297 }
9398
9499
95- _isScrolling ( ) {
96- return ( ) => this . _scrolling ;
97- }
98-
99100 _onScroll ( e ) {
100101 const { x} = e . nativeEvent . contentOffset ;
102+ this . _scrolling = true ;
101103 this . _animateScroll ( x ) ;
102104 }
103105
@@ -116,7 +118,7 @@ class ScrollableTabs extends Component {
116118 this . _animateScroll ( offsetX ) ;
117119 if ( page !== this . index ) {
118120 this . _scrolling = false ;
119- typeof this . props . onPageChanged === 'function' && this . props . onPageChanged ( page , this . _isScrolling ( ) ) ;
121+ typeof this . props . onPageChanged === 'function' && this . props . onPageChanged ( page , this . isScrolling ( ) ) ;
120122 }
121123 this . index = page ;
122124 }
@@ -128,7 +130,7 @@ class ScrollableTabs extends Component {
128130 if ( position === undefined ) {
129131 return ;
130132 }
131- typeof this . props . onPageChanged === 'function' && this . props . onPageChanged ( position , this . _isScrolling ( ) ) ;
133+ typeof this . props . onPageChanged === 'function' && this . props . onPageChanged ( position , this . isScrolling ( ) ) ;
132134 }
133135
134136
@@ -220,7 +222,7 @@ class ScrollableTabs extends Component {
220222 scrollEventThrottle = { 16 }
221223 onScroll = { this . _onScroll . bind ( this ) }
222224 onMomentumScrollBegin = { this . _onMomentumScrollBegin . bind ( this ) }
223- onMomentumScrollEnd = { this . _onMomentumScrollBegin . bind ( this ) }
225+ onMomentumScrollEnd = { this . _onMomentumScrollEnd . bind ( this ) }
224226 keyboardDismissMode = "on-drag"
225227 >
226228
0 commit comments