mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2025-02-21 11:11:23 +00:00
Hack for scroll to bottom
This commit is contained in:
parent
5f4fbabbc1
commit
5ad300017c
1 changed files with 9 additions and 0 deletions
|
@ -8,6 +8,7 @@ var Chatroom = React.createClass({
|
|||
loadMoreMessages() {
|
||||
var earliestMessage = this.props.messages[0];
|
||||
if (earliestMessage === undefined) return;
|
||||
this.disableScroll = true;
|
||||
socket.emit("message:refresh", {
|
||||
before: earliestMessage.createdAt
|
||||
});
|
||||
|
@ -17,6 +18,14 @@ var Chatroom = React.createClass({
|
|||
socket.emit("newMessage", {message: message});
|
||||
},
|
||||
|
||||
componentDidUpdate() {
|
||||
if (this.disableScroll) {
|
||||
this.disableScroll = false;
|
||||
} else {
|
||||
this.scrollToBottom();
|
||||
}
|
||||
},
|
||||
|
||||
scrollToBottom() {
|
||||
let node = React.findDOMNode(this.refs.messageContainer);
|
||||
node.scrollTop = node.scrollHeight;
|
||||
|
|
Loading…
Reference in a new issue