@@ -27,8 +27,12 @@ export default class SortableList extends Component {
27
27
showsHorizontalScrollIndicator : PropTypes . bool ,
28
28
refreshControl : PropTypes . element ,
29
29
autoscrollAreaSize : PropTypes . number ,
30
+ snapToAlignment : PropTypes . string ,
30
31
rowActivationTime : PropTypes . number ,
31
32
manuallyActivateRows : PropTypes . bool ,
33
+ scrollEventThrottle : PropTypes . number ,
34
+ decelerationRate : PropTypes . oneOf ( [ PropTypes . string , PropTypes . number ] ) ,
35
+ pagingEnabled : PropTypes . bool ,
32
36
nestedScrollEnabled : PropTypes . bool ,
33
37
disableIntervalMomentum : PropTypes . bool ,
34
38
@@ -39,15 +43,21 @@ export default class SortableList extends Component {
39
43
onChangeOrder : PropTypes . func ,
40
44
onActivateRow : PropTypes . func ,
41
45
onReleaseRow : PropTypes . func ,
46
+ onScroll : PropTypes . func ,
42
47
} ;
43
48
44
49
static defaultProps = {
45
50
sortingEnabled : true ,
46
51
scrollEnabled : true ,
47
52
autoscrollAreaSize : 60 ,
53
+ snapToAlignment : 'start' ,
48
54
manuallyActivateRows : false ,
49
55
showsVerticalScrollIndicator : true ,
50
- showsHorizontalScrollIndicator : true
56
+ showsHorizontalScrollIndicator : true ,
57
+ scrollEventThrottle : 2 ,
58
+ decelerationRate : 'normal' ,
59
+ pagingEnabled : false ,
60
+ onScroll : ( ) => { }
51
61
}
52
62
53
63
/**
@@ -134,12 +144,15 @@ export default class SortableList extends Component {
134
144
}
135
145
136
146
componentDidUpdate ( prevProps , prevState ) {
137
- const { data} = this . state ;
147
+ const { data, scrollEnabled } = this . state ;
138
148
const { data : prevData } = prevState ;
139
149
140
150
if ( data && prevData && ! shallowEqual ( data , prevData ) ) {
141
151
this . _onUpdateLayouts ( ) ;
142
152
}
153
+ if ( prevProps . scrollEnabled !== scrollEnabled ) {
154
+ this . setState ( { scrollEnabled : prevProps . scrollEnabled } )
155
+ }
143
156
}
144
157
145
158
scrollBy ( { dx = 0 , dy = 0 , animated = false } ) {
@@ -194,7 +207,20 @@ export default class SortableList extends Component {
194
207
}
195
208
196
209
render ( ) {
197
- let { contentContainerStyle, innerContainerStyle, horizontal, style, showsVerticalScrollIndicator, showsHorizontalScrollIndicator, nestedScrollEnabled, disableIntervalMomentum} = this . props ;
210
+ let {
211
+ contentContainerStyle,
212
+ innerContainerStyle,
213
+ horizontal,
214
+ style,
215
+ showsVerticalScrollIndicator,
216
+ showsHorizontalScrollIndicator,
217
+ snapToAlignment,
218
+ scrollEventThrottle,
219
+ decelerationRate,
220
+ pagingEnabled,
221
+ nestedScrollEnabled,
222
+ disableIntervalMomentum,
223
+ } = this . props ;
198
224
const { animated, contentHeight, contentWidth, scrollEnabled} = this . state ;
199
225
const containerStyle = StyleSheet . flatten ( [ style , { opacity : Number ( animated ) } ] )
200
226
innerContainerStyle = [
@@ -219,11 +245,15 @@ export default class SortableList extends Component {
219
245
ref = { this . _onRefScrollView }
220
246
horizontal = { horizontal }
221
247
contentContainerStyle = { contentContainerStyle }
222
- scrollEventThrottle = { 2 }
248
+ scrollEventThrottle = { scrollEventThrottle }
249
+ pagingEnabled = { pagingEnabled }
250
+ decelerationRate = { decelerationRate }
223
251
scrollEnabled = { scrollEnabled }
224
252
showsHorizontalScrollIndicator = { showsHorizontalScrollIndicator }
225
253
showsVerticalScrollIndicator = { showsVerticalScrollIndicator }
226
- onScroll = { this . _onScroll } >
254
+ snapToAlignment = { snapToAlignment }
255
+ onScroll = { this . _onScroll }
256
+ >
227
257
{ this . _renderHeader ( ) }
228
258
< View style = { innerContainerStyle } >
229
259
{ this . _renderRows ( ) }
@@ -625,8 +655,9 @@ export default class SortableList extends Component {
625
655
}
626
656
} ;
627
657
628
- _onScroll = ( { nativeEvent : { contentOffset} } ) => {
629
- this . _contentOffset = contentOffset ;
658
+ _onScroll = ( e ) => {
659
+ this . _contentOffset = e . nativeEvent . contentOffset ;
660
+ this . props . onScroll ( e )
630
661
} ;
631
662
632
663
_onRefContainer = ( component ) => {
0 commit comments