From b45c25642760f8c6c06f8ab3900af1106b10e107 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 8 Mar 2016 12:15:02 +0000 Subject: [PATCH] Don't forceUpdate the message panel on resize We don't really need to forceUpdate() the entire timeline panel every time something might resize it. It is sufficient to forceUpdate the ScrollPanel. --- src/components/structures/MessagePanel.js | 12 ++++++++++++ src/components/structures/RoomView.js | 2 +- src/components/structures/TimelinePanel.js | 7 +++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index 45f0b4f0f8..f622d1af8b 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -159,6 +159,18 @@ module.exports = React.createClass({ } }, + // makes the MessagePanel update itself after it is resized (due to other + // changes in the DOM) + onResize: function() { + if (!this.refs.scrollPanel) { return; } + + // we don't need to forceUpdate ourselves here, but we do need to + // forceUpdate the scrollpanel, which will make the gemini panel update + // itself and trigger a scroll position check. + console.log("MessagePanel.onResize"); + this.refs.scrollPanel.forceUpdate(); + }, + _getEventTiles: function() { var EventTile = sdk.getComponent('rooms.EventTile'); diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 3cd933eaaa..e3d60ed83b 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -1028,7 +1028,7 @@ module.exports = React.createClass({ // telling it about it. This also ensures that the scroll offset is // updated. if (this.refs.messagePanel) { - this.refs.messagePanel.forceUpdate(); + this.refs.messagePanel.onResize(); } }, diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index ff4df26179..f4747cb026 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -467,6 +467,13 @@ var TimelinePanel = React.createClass({ return null; }, + // makes the TimelinePanel update itself after it is resized (due to other + // changes in the DOM) + onResize: function() { + if (!this.refs.messagePanel) { return; } + this.refs.messagePanel.onResize(); + }, + _initTimeline: function(props) { var initialEvent = props.eventId; var pixelOffset = props.eventPixelOffset;