From 806ef11fdec3d46b8d08501d4454aa2c5bd323a1 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 16 Sep 2016 17:18:58 +0100 Subject: [PATCH 1/2] 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. --- src/components/structures/ScrollPanel.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/structures/ScrollPanel.js b/src/components/structures/ScrollPanel.js index 9a4c614720b..1c3bedfabb2 100644 --- a/src/components/structures/ScrollPanel.js +++ b/src/components/structures/ScrollPanel.js @@ -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}; }, /** From d0fd6e985fac4228dc33d5165cc0094dd33ec903 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 16 Sep 2016 17:48:08 +0100 Subject: [PATCH 2/2] Document paranoia on the startAtBottom param --- src/components/structures/ScrollPanel.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/structures/ScrollPanel.js b/src/components/structures/ScrollPanel.js index 1c3bedfabb2..6970cd190c1 100644 --- a/src/components/structures/ScrollPanel.js +++ b/src/components/structures/ScrollPanel.js @@ -79,6 +79,10 @@ module.exports = React.createClass({ /* 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,