Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #483 from matrix-org/dbkr/scrollpanel_start_at_bottom
Browse files Browse the repository at this point in the history
Add 'startAtBottom' flag
  • Loading branch information
ara4n committed Sep 16, 2016
2 parents c322a19 + d0fd6e9 commit 00d2fd4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/structures/ScrollPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ module.exports = React.createClass({
*/
stickyBottom: React.PropTypes.bool,

/* startAtBottom: if set to true, the view is assumed to start
* scrolled to the bottom.
* XXX: It's likley this is unecessary and can be derived from
* stickyBottom, but I'm adding an extra parameter to ensure
* behaviour stays the same for other uses of ScrollPanel.
* If so, let's remove this parameter down the line.
*/
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.
Expand Down Expand Up @@ -113,6 +122,7 @@ module.exports = React.createClass({
getDefaultProps: function() {
return {
stickyBottom: true,
startAtBottom: true,
onFillRequest: function(backwards) { return q(false); },
onScroll: function() {},
};
Expand Down Expand Up @@ -324,7 +334,7 @@ module.exports = React.createClass({
* child list.)
*/
resetScrollState: function() {
this.scrollState = {stuckAtBottom: true};
this.scrollState = {stuckAtBottom: this.props.startAtBottom};
},

/**
Expand Down

0 comments on commit 00d2fd4

Please sign in to comment.