Skip to content

Commit

Permalink
docs: fixed some typos
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhom committed May 2, 2020
1 parent ff98c99 commit 4568ff6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ npm install @gorhom/sticky-item
| ---------------------------- | ------------------------------------------------------------------------------------------------- | -------- | --------------------------------- | ------- |
| `itemWidth` | Item's width. | YES | number | |
| `itemHeight` | Item's height. | YES | number | |
| `separatorSize` | Flat list separator witdh. | NO | number | 10 |
| `separatorSize` | FlatList's separator width. | NO | number | 10 |
| `borderRadius` | Item & sticky border radius. | NO | number | 15 |
| `stickyItemWidth` | Sticky item's width. | YES | number | |
| `stickyItemHeight` | Sticky item's height. | YES | number | |
| `stickyItemBackgroundColors` | Sticky item's two background colors, one when sticky item is extended another when it's minimise. | YES | string[] | |
| `stickyItemBackgroundColors` | Sticky item's two background colors, one when sticky item is extended another when it's minimize. | YES | string[] | |
| `stickyItemContent` | Sticky item's content component. | YES | [`ReactNode`](./src/types.ts#L30) | |
| `onStickyItemPress` | Callback when sticky item gets pressed. | NO | function |

Expand Down
10 changes: 5 additions & 5 deletions src/StickyItemFlatList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,18 @@ function StickyItemFlatList<T>({
x,
call([x], args => {
if (tapRef.current) {
const isMinimised = args[0] > 0;
const isMinimized = args[0] > 0;
// @ts-ignore
tapRef.current.setNativeProps({
hitSlop: {
top: isMinimised
top: isMinimized
? -((itemHeight - (stickyItemWidth + separatorSize * 2)) / 2)
: 0,
left: isMinimised ? 0 : -separatorSize,
width: isMinimised
left: isMinimized ? 0 : -separatorSize,
width: isMinimized
? stickyItemWidth + separatorSize * 2
: itemWidth,
height: isMinimised
height: isMinimized
? stickyItemWidth + separatorSize * 2
: itemHeight,
},
Expand Down
44 changes: 43 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import type { FlatListProps } from 'react-native';
import Animated from 'react-native-reanimated';

export interface StickyItemProps extends Required<StickyItemConfig> {
/**
* Animated value of the flatlist x position.
* @type {Animated.Value<number>}
*/
x: Animated.Value<number>;
}

Expand All @@ -16,17 +20,51 @@ export interface StickyItemContentProps
export interface StickyItemBackgroundProps
extends Omit<StickyItemProps, 'stickyItemContent'> {
threshold: number;
stickyItemBackgroundColors: string[];
}

export interface StickyItemConfig {
/**
* Item's width.
* @type {number}
*/
itemWidth: number;
/**
* Item's height.
* @type {number}
*/
itemHeight: number;
/**
* FlatList's separator width
* @type {number}
* @default 10
*/
separatorSize?: number;
/**
* Item & sticky border radius.
* @type {number}
* @default 15
*/
borderRadius?: number;
/**
* Sticky item's width.
* @type {number}
*/
stickyItemWidth: number;
/**
* Sticky item's height.
* @type {number}
*/
stickyItemHeight: number;
/**
* Sticky item's two background colors, one when sticky item is extended
* another when it's minimize.
* @type {string[]}
*/
stickyItemBackgroundColors: string[];
/**
* Sticky item's content component.
* @type {(props: StickyItemContentProps) => React.ReactNode}
*/
stickyItemContent:
| ((props: StickyItemContentProps) => React.ReactNode)
| React.ComponentClass<StickyItemContentProps>;
Expand All @@ -35,5 +73,9 @@ export interface StickyItemConfig {
export interface StickyItemFlatListProps<T>
extends FlatListProps<T>,
StickyItemConfig {
/**
* Callback when sticky item gets pressed.
* @type {() => void}
*/
onStickyItemPress?: () => void;
}

0 comments on commit 4568ff6

Please sign in to comment.