Skip to content

Commit

Permalink
Added stickyHeaderIndices to ListView
Browse files Browse the repository at this point in the history
Summary:
Closes #3870

Alternatively I could make this a bool `stickyheader` that just adds `0` to  the `stickyHeaderIndices` passed down to the ScrollView.
Closes #4213

Reviewed By: svcscm

Differential Revision: D2807414

Pulled By: androidtrunkagent

fb-gh-sync-id: 091b6c6c91cebe175181f57b5c2785395b5db19b
  • Loading branch information
cancan101 authored and facebook-github-bot-0 committed Jan 6, 2016
1 parent 435efad commit 4bc425c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Libraries/CustomComponents/ListView/ListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ var ListView = React.createClass({
* containers. This is enabled by default.
*/
removeClippedSubviews: React.PropTypes.bool,
/**
* An array of child indices determining which children get docked to the
* top of the screen when scrolling. For example, passing
* `stickyHeaderIndices={[0]}` will cause the first child to be fixed to the
* top of the scroll view. This property is not supported in conjunction
* with `horizontal={true}`.
* @platform ios
*/
stickyHeaderIndices: PropTypes.arrayOf(PropTypes.number),
},

/**
Expand Down Expand Up @@ -242,6 +251,7 @@ var ListView = React.createClass({
renderScrollComponent: props => <ScrollView {...props} />,
scrollRenderAheadDistance: DEFAULT_SCROLL_RENDER_AHEAD,
onEndReachedThreshold: DEFAULT_END_REACHED_THRESHOLD,
stickyHeaderIndices: [],
};
},

Expand Down Expand Up @@ -394,7 +404,7 @@ var ListView = React.createClass({
}
Object.assign(props, {
onScroll: this._onScroll,
stickyHeaderIndices: sectionHeaderIndices,
stickyHeaderIndices: this.props.stickyHeaderIndices.concat(sectionHeaderIndices),

// Do not pass these events downstream to ScrollView since they will be
// registered in ListView's own ScrollResponder.Mixin
Expand Down

3 comments on commit 4bc425c

@sachinbiradar9
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work on Android?

@ide
Copy link
Contributor

@ide ide commented on 4bc425c Feb 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@009dollar no, not supported on Android.

@sachinbiradar9
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ide you may want to correct the release notes, it says Added stickyHeaderIndices to ListView – 4bc425c under Android (New feature)
https://github.com/facebook/react-native/releases/tag/v0.19.0

Please sign in to comment.