Add 'startAtBottom' flag

Controls whether a scrollPanel starts off at the bottom.

This may not be necessary and could either be derived from stickyBottom, but
this means I can be sure that the behaviour of ScrollPanel is completely
unchanged for all other uses to avoid breaking any other uses of
ScrollPanel.
This commit is contained in:
David Baker 2016-09-16 17:18:58 +01:00
parent 1341ffca59
commit 806ef11fde

View file

@ -77,6 +77,11 @@ module.exports = React.createClass({
*/
stickyBottom: React.PropTypes.bool,
/* startAtBottom: if set to true, the view is assumed to start
* scrolled to the bottom.
*/
startAtBottom: React.PropTypes.bool,
/* onFillRequest(backwards): a callback which is called on scroll when
* the user nears the start (backwards = true) or end (backwards =
* false) of the list.
@ -113,6 +118,7 @@ module.exports = React.createClass({
getDefaultProps: function() {
return {
stickyBottom: true,
startAtBottom: true,
onFillRequest: function(backwards) { return q(false); },
onScroll: function() {},
};
@ -324,7 +330,7 @@ module.exports = React.createClass({
* child list.)
*/
resetScrollState: function() {
this.scrollState = {stuckAtBottom: true};
this.scrollState = {stuckAtBottom: this.props.startAtBottom};
},
/**