|
| 1 | +import { RefObject } from 'react'; |
| 2 | +import { LayoutChangeEvent, ScrollView, FlatList, NativeSyntheticEvent, NativeScrollEvent } from 'react-native'; |
| 3 | +export declare enum OffsetType { |
| 4 | + CENTER = "CENTER", |
| 5 | + DYNAMIC = "DYNAMIC", |
| 6 | + LEFT = "LEFT", |
| 7 | + RIGHT = "RIGHT" |
| 8 | +} |
| 9 | +export declare type Props = { |
| 10 | + /** |
| 11 | + * A reference to the ScrollView (or FlatList) which the items are in |
| 12 | + */ |
| 13 | + scrollViewRef: RefObject<ScrollView | FlatList>; |
| 14 | + /** |
| 15 | + * The number of items |
| 16 | + */ |
| 17 | + itemsCount: number; |
| 18 | + /** |
| 19 | + * The selected item's index |
| 20 | + */ |
| 21 | + selectedIndex?: number; |
| 22 | + /** |
| 23 | + * Where would the item be located (default to CENTER) |
| 24 | + */ |
| 25 | + offsetType?: OffsetType; |
| 26 | + /** |
| 27 | + * Add a margin to the offset (default to true) |
| 28 | + * This gives a better UX |
| 29 | + * Not relevant to OffsetType.CENTER |
| 30 | + */ |
| 31 | + addOffsetMargin?: boolean; |
| 32 | + /** |
| 33 | + * How much space (padding \ margin) is there on he left\right of the items |
| 34 | + */ |
| 35 | + sideSpacing?: number; |
| 36 | + /** |
| 37 | + * How much space (padding \ margin) is there between each item |
| 38 | + */ |
| 39 | + innerSpacing?: number; |
| 40 | +}; |
| 41 | +export declare type ResultProps = { |
| 42 | + /** |
| 43 | + * This should be called by each ot the items' onLayout |
| 44 | + */ |
| 45 | + onItemLayout: (event: LayoutChangeEvent, index: number) => void; |
| 46 | + /** |
| 47 | + * This should be called by the ScrollView (or FlatList) |
| 48 | + * If this is not used OffsetType.DYNAMIC will not work properly |
| 49 | + */ |
| 50 | + onScroll: (event: NativeSyntheticEvent<NativeScrollEvent>) => void; |
| 51 | + /** |
| 52 | + * The items' width |
| 53 | + */ |
| 54 | + itemsWidths: number[]; |
| 55 | + /** |
| 56 | + * Use in order to focus the item with the specified index |
| 57 | + */ |
| 58 | + focusIndex: (index: number, animated?: boolean) => void; |
| 59 | +}; |
| 60 | +declare const focusItemsHelper: (props: Props) => ResultProps; |
| 61 | +export default focusItemsHelper; |
0 commit comments