Scroll to bottom
This commit is contained in:
parent
eff6dcb514
commit
f0390dae63
@ -4,7 +4,6 @@
|
|||||||
class="window">
|
class="window">
|
||||||
<div
|
<div
|
||||||
id="chat"
|
id="chat"
|
||||||
ref="chat"
|
|
||||||
:data-id="channel.id"
|
:data-id="channel.id"
|
||||||
:class="{
|
:class="{
|
||||||
'hide-motd': !settings.motd,
|
'hide-motd': !settings.motd,
|
||||||
@ -45,7 +44,10 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="chat-content">
|
<div class="chat-content">
|
||||||
<div class="chat">
|
<div
|
||||||
|
ref="chat"
|
||||||
|
class="chat"
|
||||||
|
>
|
||||||
<div class="show-more">
|
<div class="show-more">
|
||||||
<button
|
<button
|
||||||
ref="loadMoreButton"
|
ref="loadMoreButton"
|
||||||
@ -97,6 +99,10 @@ export default {
|
|||||||
root: this.$refs.chat,
|
root: this.$refs.chat,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.chat.scrollTop = this.$refs.chat.scrollHeight;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (this.historyObserver) {
|
if (this.historyObserver) {
|
||||||
@ -108,6 +114,19 @@ export default {
|
|||||||
this.historyObserver.disconnect();
|
this.historyObserver.disconnect();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
"channel.messages": function() {
|
||||||
|
const el = this.$refs.chat;
|
||||||
|
|
||||||
|
if (el.scrollHeight - el.scrollTop - el.offsetHeight > 30) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$nextTick(() => {
|
||||||
|
el.scrollTop = el.scrollHeight;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onShowMoreClick() {
|
onShowMoreClick() {
|
||||||
let lastMessage = this.channel.messages[0];
|
let lastMessage = this.channel.messages[0];
|
||||||
|
Loading…
Reference in New Issue
Block a user