Skip to content

Commit

Permalink
fix scrolling on old mobile devices
Browse files Browse the repository at this point in the history
  • Loading branch information
yamaha252 committed Dec 10, 2018
1 parent f8d4504 commit a8244c2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/chat/message-area.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ const dayInMillis = 60 * 60 * 24 * 1000;

export default class MessageArea extends Component {
scrollToBottom() {
this.messagesEnd.scrollIntoView({ behavior: 'smooth' });
if (this.chat && 'scrollTo' in this.chat) {
this.chat.scrollTo({
top: this.chat.scrollHeight - this.chat.clientHeight,
behavior: 'smooth',
});
} else {
this.chat.scrollTop = this.chat.scrollHeight - this.chat.clientHeight;
}
}

focus() {
Expand Down Expand Up @@ -46,7 +53,6 @@ export default class MessageArea extends Component {
</div>
);
})}
<div ref={(el) => {this.messagesEnd = el;}}/>
</div>
);
}
Expand Down

0 comments on commit a8244c2

Please sign in to comment.