mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 01:40:08 +00:00
Support API "scrollTo" in RecyclerViewBackedScrollView on Android
Summary: In Android `RecyclerViewBackedScrollView` didn't provide the `scrollTo` API, however iOS does. If a ListView was created with `RecyclerViewBackedScrollView` as its `renderScrollComponent`, then calling `scrollTo` wouldn't work. This diff enables the `scrollTo` API in `RecyclerViewBackedScrollView` on Android. Reviewed By: dmmiller Differential Revision: D3605233 fbshipit-source-id: f192053361f45453e5fce3fb6038ab03ac4025af
This commit is contained in:
parent
a07026d075
commit
235c059605
@ -75,6 +75,30 @@ var RecyclerViewBackedScrollView = React.createClass({
|
||||
this.props.onContentSizeChange(width, height);
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper function to scroll to a specific point in the scrollview.
|
||||
* This is currently used to help focus on child textviews, but can also
|
||||
* be used to quickly scroll to any element we want to focus. Syntax:
|
||||
*
|
||||
* scrollResponderScrollTo(options: {x: number = 0; y: number = 0; animated: boolean = true})
|
||||
*
|
||||
* Note: The weird argument signature is due to the fact that, for historical reasons,
|
||||
* the function also accepts separate arguments as as alternative to the options object.
|
||||
* This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.
|
||||
*/
|
||||
scrollTo: function(
|
||||
y?: number | { x?: number, y?: number, animated?: boolean },
|
||||
x?: number,
|
||||
animated?: boolean
|
||||
) {
|
||||
if (typeof y === 'number') {
|
||||
console.warn('`scrollTo(y, x, animated)` is deprecated. Use `scrollTo({x: 5, y: 5, animated: true})` instead.');
|
||||
} else {
|
||||
({x, y, animated} = y || {});
|
||||
}
|
||||
this.getScrollResponder().scrollResponderScrollTo({x: x || 0, y: y || 0, animated: animated !== false});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var recyclerProps = {
|
||||
...this.props,
|
||||
|
Loading…
x
Reference in New Issue
Block a user