Chats: fix #418 scrolling resize issue

better-alerts
Alex Gleason 2020-09-11 22:44:09 -05:00
rodzic 0c15e3235a
commit 5682688aed
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 6 dodań i 0 usunięć

Wyświetl plik

@ -89,11 +89,16 @@ class ChatMessageList extends ImmutablePureComponent {
return scrollBottom < elem.offsetHeight * 1.5; return scrollBottom < elem.offsetHeight * 1.5;
} }
handleResize = (e) => {
if (this.isNearBottom()) this.scrollToBottom();
}
componentDidMount() { componentDidMount() {
const { dispatch, chatId } = this.props; const { dispatch, chatId } = this.props;
dispatch(fetchChatMessages(chatId)); dispatch(fetchChatMessages(chatId));
this.node.addEventListener('scroll', this.handleScroll); this.node.addEventListener('scroll', this.handleScroll);
window.addEventListener('resize', this.handleResize);
this.scrollToBottom(); this.scrollToBottom();
} }
@ -125,6 +130,7 @@ class ChatMessageList extends ImmutablePureComponent {
componentWillUnmount() { componentWillUnmount() {
this.node.removeEventListener('scroll', this.handleScroll); this.node.removeEventListener('scroll', this.handleScroll);
window.removeEventListener('resize', this.handleResize);
} }
handleLoadMore = () => { handleLoadMore = () => {