Skip to content

Commit f16a2fb

Browse files
authored
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.
1 parent f85bdc5 commit f16a2fb

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

docs/scrollview.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -568,29 +568,33 @@ The current scale of the scroll view content. The default value is 1.0.
568568
### `scrollTo()`
569569

570570
```javascript
571-
scrollTo(([y]: number), object, ([x]: number), ([animated]: boolean));
571+
scrollTo(([y]: number), object, ([x]: number), ([animated]: boolean), ([duration]: number));
572572
```
573573

574-
Scrolls to a given x, y offset, either immediately or with a smooth animation.
574+
Scrolls to a given x, y offset, either immediately or with a smooth animation. For Android, you may specify a "duration" instead of using "animated", which simply resolves to a default duration of 250 milliseconds. Using `{animated: true}` for Android is the same as specifing `{duration: 250}`.
575575

576576
Example:
577577

578-
`scrollTo({x: 0, y: 0, animated: true})`
578+
`scrollTo({x: 0, y: 0, animated: true, duration: 0})`
579579

580-
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.
580+
Note 1: 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.
581+
582+
Note 2: The "duration" argument is only currently supported for Android.
581583

582584
---
583585

584586
### `scrollToEnd()`
585587

586588
```javascript
587-
scrollToEnd(([options]: object));
589+
scrollToEnd(([options]: {animated: boolean, duration: number}));
588590
```
589591

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

592594
Use `scrollToEnd({animated: true})` for smooth animated scrolling, `scrollToEnd({animated: false})` for immediate scrolling. If no options are passed, `animated` defaults to true.
593595

596+
For Android, you may specify a "duration" instead of using "animated", which simply resolves to a default duration of 250 milliseconds. Using `{animated: true}` for Android is the same as specifing `{duration: 250}`.
597+
594598
---
595599

596600
### `scrollWithoutAnimationTo()`

0 commit comments

Comments
 (0)