Skip to content

Commit

Permalink
Exposed progressViewOffset to VirtualizedList and FlatList
Browse files Browse the repository at this point in the history
Reviewed By: sahrens

Differential Revision: D5204107

fbshipit-source-id: df2928830f84ea012d532f24c776dee8d2b96989
  • Loading branch information
Kexi Long authored and facebook-github-bot committed Jun 8, 2017
1 parent 5840a90 commit a0a7d97
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ type OptionalProps<ItemT> = {
viewableItems: Array<ViewToken>,
changed: Array<ViewToken>,
}) => void,
/**
* Set this when offset is needed for the loading indicator to show correctly.
* @platform android
*/
progressViewOffset?: number,
legacyImplementation?: ?boolean,
/**
* Set this true while waiting for new data from a refresh.
Expand Down Expand Up @@ -326,7 +331,7 @@ class FlatList<ItemT> extends React.PureComponent<DefaultProps, Props<ItemT>, vo

/**
* Scroll to a specific content pixel offset in the list.
*
*
* Check out [scrollToOffset](docs/virtualizedlist.html#scrolltooffset) of VirtualizedList
*/
scrollToOffset(params: {animated?: ?boolean, offset: number}) {
Expand Down
11 changes: 9 additions & 2 deletions Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ type OptionalProps = {
viewableItems: Array<ViewToken>,
changed: Array<ViewToken>,
}) => void,
/**
* Set this when offset is needed for the loading indicator to show correctly.
* @platform android
*/
progressViewOffset?: number,
/**
* Set this true while waiting for new data from a refresh.
*/
Expand Down Expand Up @@ -240,11 +245,11 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {

/**
* Scroll to a specific content pixel offset in the list.
*
*
* Param `offset` expects the offset to scroll to.
* In case of `horizontal` is true, the offset is the x-value,
* in any other case the offset is the y-value.
*
*
* Param `animated` (`true` by default) defines whether the list
* should do an animation while scrolling.
*/
Expand Down Expand Up @@ -303,13 +308,15 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
'`refreshing` prop must be set as a boolean in order to use `onRefresh`, but got `' +
JSON.stringify(props.refreshing) + '`',
);

return (
<ScrollView
{...props}
refreshControl={
<RefreshControl
refreshing={props.refreshing}
onRefresh={props.onRefresh}
progressViewOffset={props.progressViewOffset}
/>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ exports[`FlatList renders all the bells and whistles 1`] = `
refreshControl={
<RefreshControlMock
onRefresh={[Function]}
progressViewOffset={undefined}
refreshing={false}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ exports[`SectionList renders all the bells and whistles 1`] = `
refreshControl={
<RefreshControlMock
onRefresh={[Function]}
progressViewOffset={undefined}
refreshing={false}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ exports[`VirtualizedList renders all the bells and whistles 1`] = `
refreshControl={
<RefreshControlMock
onRefresh={[Function]}
progressViewOffset={undefined}
refreshing={false}
/>
}
Expand Down

0 comments on commit a0a7d97

Please sign in to comment.