From 65b4249fbe2e4d428191dc857609dbd57b690324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Caetano?= Date: Mon, 11 Feb 2019 15:07:19 -0200 Subject: [PATCH] [react-native]: add snap types to ScrollViewProps --- types/react-native/index.d.ts | 53 ++++++++++++++++++++++--------- types/react-native/test/index.tsx | 3 ++ 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 2be1a48992..ad641ce049 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -6297,21 +6297,6 @@ export interface ScrollViewPropsIOS { */ scrollsToTop?: boolean; - /** - * When snapToInterval is set, snapToAlignment will define the relationship of the the snapping to the scroll view. - * - start (the default) will align the snap at the left (horizontal) or top (vertical) - * - center will align the snap in the center - * - end will align the snap at the right (horizontal) or bottom (vertical) - */ - snapToAlignment?: "start" | "center" | "end"; - - /** - * When set, causes the scroll view to stop at multiples of the value of snapToInterval. - * This can be used for paginating through children that have lengths smaller than the scroll view. - * Used in combination with snapToAlignment. - */ - snapToInterval?: number; - /** * An array of child indices determining which children get docked to the * top of the screen when scrolling. For example passing @@ -6484,6 +6469,44 @@ export interface ScrollViewProps extends ViewProps, ScrollViewPropsIOS, ScrollVi * functionality for the ScrollView. */ refreshControl?: React.ReactElement; + + /** + * When `snapToInterval` is set, `snapToAlignment` will define the relationship of the the snapping to the scroll view. + * - `start` (the default) will align the snap at the left (horizontal) or top (vertical) + * - `center` will align the snap in the center + * - `end` will align the snap at the right (horizontal) or bottom (vertical) + */ + snapToAlignment?: "start" | "center" | "end"; + + /** + * When set, causes the scroll view to stop at multiples of the value of `snapToInterval`. + * This can be used for paginating through children that have lengths smaller than the scroll view. + * Used in combination with `snapToAlignment` and `decelerationRate="fast"`. Overrides less + * configurable `pagingEnabled` prop. + */ + snapToInterval?: number; + + /** + * When set, causes the scroll view to stop at the defined offsets. This can be used for + * paginating through variously sized children that have lengths smaller than the scroll view. + * Typically used in combination with `decelerationRate="fast"`. Overrides less configurable + * `pagingEnabled` and `snapToInterval` props. + */ + snapToOffsets?: number[]; + + /** + * Use in conjuction with `snapToOffsets`. By default, the beginning of the list counts as a + * snap offset. Set `snapToStart` to false to disable this behavior and allow the list to scroll + * freely between its start and the first `snapToOffsets` offset. The default value is true. + */ + snapToStart?: boolean; + + /** + * Use in conjuction with `snapToOffsets`. By default, the end of the list counts as a snap + * offset. Set `snapToEnd` to false to disable this behavior and allow the list to scroll freely + * between its end and the last `snapToOffsets` offset. The default value is true. + */ + snapToEnd?: boolean; } declare class ScrollViewComponent extends React.Component {} diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index dfa327ce7b..622e2b28c8 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -454,6 +454,9 @@ class ScrollerListComponentTest extends React.Component<{}, { dataSource: ListVi nestedScrollEnabled={true} invertStickyHeaders={true} contentOffset={{ x: 0, y: 0 }} + snapToStart={false} + snapToEnd={false} + snapToOffsets={[100, 300, 500]} {...props} style={[scrollViewStyle1.scrollView, scrollViewStyle2]} />