more usable [scroll to bottom] button

This commit is contained in:
or-else
2022-05-19 18:21:35 -07:00
parent 6ffc03e8bd
commit 46b6a816eb
5 changed files with 8 additions and 7 deletions
+4 -3
View File
@@ -431,7 +431,8 @@ class MessagesView extends React.Component {
const pos = event.target.scrollHeight - event.target.scrollTop - event.target.offsetHeight; const pos = event.target.scrollHeight - event.target.scrollTop - event.target.offsetHeight;
this.setState({ this.setState({
scrollPosition: pos, scrollPosition: pos,
showGoToLastButton: pos > SHOW_GO_TO_LAST_DIST, // Show [go to latest message] if far enough from bottom and scrolling down.
showGoToLastButton: (pos > SHOW_GO_TO_LAST_DIST) && (pos < this.state.scrollPosition),
}); });
if (this.state.fetchingMessages) { if (this.state.fetchingMessages) {
@@ -579,8 +580,8 @@ class MessagesView extends React.Component {
clearTimeout(this.keyPressTimer) clearTimeout(this.keyPressTimer)
this.setState({messageCount: topic.messageCount(), typingIndicator: false}); this.setState({messageCount: topic.messageCount(), typingIndicator: false});
// Scroll to the bottom if the message is added to the end of the message list. // Scroll to the bottom if the message is added to the end of the message
// TODO: This should be replaced by showing a "scroll to bottom" button. // list if already at the bottom, otherwise show [go to latest] button.
if (topic.isNewMessage(msg.seq)) { if (topic.isNewMessage(msg.seq)) {
if (this.state.scrollPosition > SHOW_GO_TO_LAST_DIST) { if (this.state.scrollPosition > SHOW_GO_TO_LAST_DIST) {
this.setState({showGoToLastButton: true}); this.setState({showGoToLastButton: true});
+1 -1
View File
@@ -5771,7 +5771,7 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
const pos = event.target.scrollHeight - event.target.scrollTop - event.target.offsetHeight; const pos = event.target.scrollHeight - event.target.scrollTop - event.target.offsetHeight;
this.setState({ this.setState({
scrollPosition: pos, scrollPosition: pos,
showGoToLastButton: pos > SHOW_GO_TO_LAST_DIST showGoToLastButton: pos > SHOW_GO_TO_LAST_DIST && pos < this.state.scrollPosition
}); });
if (this.state.fetchingMessages) { if (this.state.fetchingMessages) {
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long