Auto-scroll checkbox

This commit is contained in:
Noah 2023-03-24 21:56:40 -07:00
parent 5c311da521
commit ea4c597cbd
3 changed files with 21 additions and 0 deletions

View File

@ -64,6 +64,15 @@ body {
grid-column: 2; grid-column: 2;
grid-row: 2; grid-row: 2;
overflow: hidden; overflow: hidden;
position: relative;
}
/* Auto-scroll checkbox in the corner */
.chat-column >.autoscroll-field {
position: absolute;
z-index: 39; /* just below modal shadow */
right: 6px;
bottom: 4px;
} }
/* Footer row: message entry box */ /* Footer row: message entry box */

View File

@ -120,6 +120,7 @@ const app = Vue.createApp({
// } // }
}, },
historyScrollbox: null, historyScrollbox: null,
autoscroll: true, // scroll to bottom on new messages
DMs: {}, DMs: {},
// Responsive CSS controls for mobile. // Responsive CSS controls for mobile.
@ -1083,6 +1084,8 @@ const app = Vue.createApp({
}, },
scrollHistory() { scrollHistory() {
if (!this.autoscroll) return;
window.requestAnimationFrame(() => { window.requestAnimationFrame(() => {
this.historyScrollbox.scroll({ this.historyScrollbox.scroll({
top: this.historyScrollbox.scrollHeight, top: this.historyScrollbox.scrollHeight,

View File

@ -425,6 +425,15 @@
<!-- Middle Column: Chat Room/History --> <!-- Middle Column: Chat Room/History -->
<div class="chat-column"> <div class="chat-column">
<div class="autoscroll-field tag">
<label class="checkbox is-size-6" title="Automatically scroll when new chat messages come in.">
<input type="checkbox"
v-model="autoscroll"
:value="true">
Auto-scroll
</label>
</div>
<div class="card grid-card"> <div class="card grid-card">
<header class="card-header has-background-link"> <header class="card-header has-background-link">
<div class="columns is-mobile card-header-title has-text-light"> <div class="columns is-mobile card-header-title has-text-light">