@@ -125,19 +125,6 @@ type IOSProps = $ReadOnly<{|
125
125
* @platform ios
126
126
*/
127
127
centerContent ?: ?boolean ,
128
- /**
129
- * A floating-point number that determines how quickly the scroll view
130
- * decelerates after the user lifts their finger. You may also use string
131
- * shortcuts `"normal"` and `"fast"` which match the underlying iOS settings
132
- * for `UIScrollViewDecelerationRateNormal` and
133
- * `UIScrollViewDecelerationRateFast` respectively.
134
- *
135
- * - `'normal'`: 0.998 (the default)
136
- * - `'fast'`: 0.99
137
- *
138
- * @platform ios
139
- */
140
- decelerationRate ?: ?( 'fast' | 'normal' | number ) ,
141
128
/**
142
129
* The style of the scroll indicators.
143
130
*
@@ -353,6 +340,17 @@ export type Props = $ReadOnly<{|
353
340
* ```
354
341
*/
355
342
contentContainerStyle ?: ?ViewStyleProp ,
343
+ /**
344
+ * A floating-point number that determines how quickly the scroll view
345
+ * decelerates after the user lifts their finger. You may also use string
346
+ * shortcuts `"normal"` and `"fast"` which match the underlying iOS settings
347
+ * for `UIScrollViewDecelerationRateNormal` and
348
+ * `UIScrollViewDecelerationRateFast` respectively.
349
+ *
350
+ * - `'normal'`: 0.998 on iOS, 0.985 on Android (the default)
351
+ * - `'fast'`: 0.99 on iOS, 0.9 on Android
352
+ */
353
+ decelerationRate ?: ?( 'fast' | 'normal' | number ) ,
356
354
/**
357
355
* When true, the scroll view's children are arranged horizontally in a row
358
356
* instead of vertically in a column. The default value is false.
@@ -462,12 +460,20 @@ export type Props = $ReadOnly<{|
462
460
* When set, causes the scroll view to stop at multiples of the value of
463
461
* `snapToInterval`. This can be used for paginating through children
464
462
* that have lengths smaller than the scroll view. Typically used in
465
- * combination with `snapToAlignment` and `decelerationRate="fast"` on ios.
466
- * Overrides less configurable `pagingEnabled` prop.
463
+ * combination with `snapToAlignment` and `decelerationRate="fast"`.
467
464
*
468
- * Supported for horizontal scrollview on android .
465
+ * Overrides less configurable `pagingEnabled` prop .
469
466
*/
470
467
snapToInterval ?: ?number ,
468
+ /**
469
+ * When set, causes the scroll view to stop at the defined offsets.
470
+ * This can be used for paginating through variously sized children
471
+ * that have lengths smaller than the scroll view. Typically used in
472
+ * combination with `decelerationRate="fast"`.
473
+ *
474
+ * Overrides less configurable `pagingEnabled` and `snapToInterval` props.
475
+ */
476
+ snapToOffsets ?: ?$ReadOnlyArray < number > ,
471
477
/**
472
478
* Experimental: When true, offscreen child views (whose `overflow` value is
473
479
* `hidden`) are removed from their native backing superview when offscreen.
@@ -772,10 +778,6 @@ const ScrollView = createReactClass({
772
778
} else {
773
779
ScrollViewClass = RCTScrollView ;
774
780
ScrollContentContainerViewClass = RCTScrollContentView ;
775
- warning (
776
- this . props . snapToInterval == null || ! this . props . pagingEnabled ,
777
- 'snapToInterval is currently ignored when pagingEnabled is true.' ,
778
- ) ;
779
781
}
780
782
781
783
invariant (
@@ -919,6 +921,19 @@ const ScrollView = createReactClass({
919
921
? true
920
922
: false ,
921
923
DEPRECATED_sendUpdatedChildFrames ,
924
+ // pagingEnabled is overridden by snapToInterval / snapToOffsets
925
+ pagingEnabled : Platform . select ( {
926
+ // on iOS, pagingEnabled must be set to false to have snapToInterval / snapToOffsets work
927
+ ios :
928
+ this . props . pagingEnabled &&
929
+ this . props . snapToInterval == null &&
930
+ this . props . snapToOffsets == null ,
931
+ // on Android, pagingEnabled must be set to true to have snapToInterval / snapToOffsets work
932
+ android :
933
+ this . props . pagingEnabled ||
934
+ this . props . snapToInterval != null ||
935
+ this . props . snapToOffsets != null ,
936
+ } ) ,
922
937
} ;
923
938
924
939
const { decelerationRate} = this . props ;
0 commit comments