diff --git a/Libraries/Lists/FlatList.js b/Libraries/Lists/FlatList.js index 70c21670c26536..89368a11729745 100644 --- a/Libraries/Lists/FlatList.js +++ b/Libraries/Lists/FlatList.js @@ -173,7 +173,15 @@ class FlatList extends React.PureComponent, vo scrollToEnd(params?: ?{animated?: ?boolean}) { this._listRef.scrollToEnd(params); } - + /** + * Scrolls to a given x, y offset, either immediately or with a smooth animation. + * + * See `ScrollView#scrollTo`. + */ + scrollTo(...args: Array) { + if (this._listRef && this._listRef.scrollTo) { + this._listRef.scrollTo(...args); + } /** * Scrolls to the item at a the specified index such that it is positioned in the viewable area * such that `viewPosition` 0 places it at the top, 1 at the bottom, and 0.5 centered in the diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index fc64a70c8d43f1..64176f03385611 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -170,7 +170,16 @@ class VirtualizedList extends React.PureComponent { this.props.horizontal ? {x: offset, animated} : {y: offset, animated} ); } - + /** + * Scrolls to a given x, y offset, either immediately or with a smooth animation. + * + * See `ScrollView#scrollTo`. + */ + scrollTo(...args: Array) { + if (this._scrollRef && this._scrollRef.scrollTo) { + this._scrollRef.scrollTo(...args); + } + } // scrollToIndex may be janky without getItemLayout prop scrollToIndex(params: {animated?: ?boolean, index: number, viewPosition?: number}) { const {data, horizontal, getItemCount, getItemLayout} = this.props;