Skip to content

Commit

Permalink
update(README): add "DuoDragDrop ref value" API
Browse files Browse the repository at this point in the history
  • Loading branch information
jamsch committed Sep 30, 2021
1 parent fb80481 commit ca2c8a9
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Duolingo-style drag and drop for React Native using `react-native-gesture-handle

![https://i.imgur.com/1YkxXk3.gif](https://i.imgur.com/1YkxXk3.gif)

## Pre-requisites
## Prerequisites

Please make sure you have the the following dependencies installed in your project before continuing:

Expand Down Expand Up @@ -53,6 +53,26 @@ export default App;
| renderPlaceholder | (props: {style: StyleProp\<ViewStyle\>}) => JSX.Element | (Optional) Overrides the default placeholder renderer |
| renderLines | (props: { numLines: number; containerHeight: number; lineHeight: number }) => JSX.Element | (Optional) Overrides the default lines renderer |

## DuoDragDrop ref value

```ts
/** Returns an ordered list of words that are in the "word bank" as well as answered */
getWords(): { answered: string[]; bank: string[] };
/** Returns an array of words that are outside the "word bank" */
getAnsweredWords(): string[];
/*
* Gets the order value of each word by the word's index.
* -1 indicates that it's in the "bank"
* e.g. ["hello", "world", "foo", "bar"] -> [1, -1, 0, 2] corresponds to:
* - ["hello", "foo", "bar"] (unordered) or
* - ["foo", "hello", "bar"] (ordered) in the "answered" pile
* - and ["world"] in the "bank" pile
*/
getOffsets(): number[];
/* Animates the word buttons to move to new positions */
setOffsets(newOffsets: number[]): void;
```

## Fetching words in the "bank" or "answered" pile

You can use refs to find whether words are in the "answered" pile or in the "bank".
Expand Down

0 comments on commit ca2c8a9

Please sign in to comment.