From f16a2fbdcee2419ec20cb81cd6ec3eb81a18eb0e Mon Sep 17 00:00:00 2001 From: Danny Cochran Date: Wed, 3 Jan 2018 10:10:36 -0800 Subject: [PATCH 1/2] Update scrollview.md to reflect duration argument https://github.com/facebook/react-native/pull/17422 adds the ability to control the duration of a scrollView animation, for Android only. --- docs/scrollview.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/scrollview.md b/docs/scrollview.md index a0e078f1d64..fe62c512b62 100644 --- a/docs/scrollview.md +++ b/docs/scrollview.md @@ -568,29 +568,33 @@ The current scale of the scroll view content. The default value is 1.0. ### `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 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}`. Example: -`scrollTo({x: 0, y: 0, animated: true})` +`scrollTo({x: 0, y: 0, animated: true, duration: 0})` -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. +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. + +Note 2: The "duration" argument is only currently supported for Android. --- ### `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. +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}`. + --- ### `scrollWithoutAnimationTo()` From d1c3e4c425306e95b500a5652b1c04d1782450af Mon Sep 17 00:00:00 2001 From: Danny Cochran Date: Tue, 10 Apr 2018 13:23:09 -0700 Subject: [PATCH 2/2] sync comments with ScrollView.js --- docs/scrollview.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/scrollview.md b/docs/scrollview.md index fe62c512b62..6beba24310c 100644 --- a/docs/scrollview.md +++ b/docs/scrollview.md @@ -570,16 +570,17 @@ The current scale of the scroll view content. The default value is 1.0. ```javascript scrollTo(([y]: number), object, ([x]: number), ([animated]: boolean), ([duration]: number)); ``` - -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}`. +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, duration: 0})` +`scrollTo({x: 0, y: 0, animated: true})` + +Example with duration (Android only): -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. +`scrollTo({x: 0, y: 0, duration: 500})` -Note 2: The "duration" argument is only currently supported for Android. +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. --- @@ -591,9 +592,7 @@ 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. - -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}`. +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. ---