Skip to content

Commit

Permalink
Update scrollview.md to reflect duration argument (#115)
Browse files Browse the repository at this point in the history
* Update scrollview.md to reflect duration argument

facebook/react-native#17422 adds the ability to control the duration of a scrollView animation, for Android only.

* sync comments with ScrollView.js
  • Loading branch information
JackWillie committed Feb 7, 2019
1 parent c1de237 commit 4fb05f4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions docs/scrollview.md
Original file line number Diff line number Diff line change
Expand Up @@ -612,28 +612,31 @@ Enables nested scrolling for Android API level 21+. Nested scrolling is supporte
### `scrollTo()`

```javascript
scrollTo(([y]: number), object, ([x]: number), ([animated]: boolean));
scrollTo(([y]: number), object, ([x]: number), ([animated]: boolean), ([duration]: number));
```

Scrolls to a given x, y offset, either immediately or with a smooth animation.
Scrolls to a given x, y offset, either immediately, with a smooth animation, or, for Android only, a custom animation duration time.

Example:

`scrollTo({x: 0, y: 0, animated: true})`

Example with duration (Android only):

`scrollTo({x: 0, y: 0, duration: 500})`

Note: The weird function signature is due to the fact that, for historical reasons, the function also accepts separate arguments as an alternative to the options object. This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.

---

### `scrollToEnd()`

```javascript
scrollToEnd(([options]: object));
scrollToEnd(([options]: {animated: boolean, duration: number}));
```

If this is a vertical ScrollView scrolls to the bottom. If this is a horizontal ScrollView scrolls to the right.

Use `scrollToEnd({animated: true})` for smooth animated scrolling, `scrollToEnd({animated: false})` for immediate scrolling. If no options are passed, `animated` defaults to true.
Use `scrollToEnd({animated: true})` for smooth animated scrolling, `scrollToEnd({animated: false})` for immediate scrolling. For Android, you may specify a duration, e.g. `scrollToEnd({duration: 500})` for a controlled duration scroll. If no options are passed, `animated` defaults to true.

---

Expand Down

0 comments on commit 4fb05f4

Please sign in to comment.