Use throttle for handleResize instead
This commit is contained in:
parent
a1909b72f2
commit
5deac9f5e0
1 changed files with 4 additions and 4 deletions
|
@ -110,9 +110,9 @@ class ChatMessageList extends ImmutablePureComponent {
|
||||||
return scrollBottom < elem.offsetHeight * 1.5;
|
return scrollBottom < elem.offsetHeight * 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleResize = (e) => {
|
handleResize = throttle((e) => {
|
||||||
if (this.isNearBottom() && !this.state.loading) this.scrollToBottom();
|
if (this.isNearBottom()) this.scrollToBottom();
|
||||||
}
|
}, 150);
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { dispatch, chatId } = this.props;
|
const { dispatch, chatId } = this.props;
|
||||||
|
@ -137,7 +137,7 @@ class ChatMessageList extends ImmutablePureComponent {
|
||||||
const { initialLoad } = this.state;
|
const { initialLoad } = this.state;
|
||||||
const oldCount = prevProps.chatMessages.count();
|
const oldCount = prevProps.chatMessages.count();
|
||||||
const newCount = this.props.chatMessages.count();
|
const newCount = this.props.chatMessages.count();
|
||||||
const isNearBottom = this.isNearBottom();
|
const isNearBottom = throttle(this.isNearBottom(), 150);
|
||||||
const historyAdded = prevProps.chatMessages.getIn([0, 'id']) !== this.props.chatMessages.getIn([0, 'id']);
|
const historyAdded = prevProps.chatMessages.getIn([0, 'id']) !== this.props.chatMessages.getIn([0, 'id']);
|
||||||
|
|
||||||
// Retain scroll bar position when loading old messages
|
// Retain scroll bar position when loading old messages
|
||||||
|
|
Loading…
Reference in a new issue