Keep scroll position when scrolling up
This commit is contained in:
parent
dbe95fcc13
commit
499beb0257
@ -186,6 +186,16 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (el.scrollHeight - el.scrollTop - el.offsetHeight > 30) {
|
if (el.scrollHeight - el.scrollTop - el.offsetHeight > 30) {
|
||||||
|
if (this.channel.historyLoading) {
|
||||||
|
const heightOld = el.scrollHeight - el.scrollTop;
|
||||||
|
|
||||||
|
this.isWaitingForNextTick = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.isWaitingForNextTick = false;
|
||||||
|
el.scrollTop = el.scrollHeight - heightOld;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const socket = require("../socket");
|
const socket = require("../socket");
|
||||||
const {findChannel} = require("../vue");
|
const {vueApp, findChannel} = require("../vue");
|
||||||
|
|
||||||
socket.on("more", function(data) {
|
socket.on("more", function(data) {
|
||||||
const channel = findChannel(data.chan);
|
const channel = findChannel(data.chan);
|
||||||
@ -12,5 +12,8 @@ socket.on("more", function(data) {
|
|||||||
|
|
||||||
channel.channel.moreHistoryAvailable = data.moreHistoryAvailable;
|
channel.channel.moreHistoryAvailable = data.moreHistoryAvailable;
|
||||||
channel.channel.messages.unshift(...data.messages);
|
channel.channel.messages.unshift(...data.messages);
|
||||||
channel.channel.historyLoading = false;
|
|
||||||
|
vueApp.$nextTick(() => {
|
||||||
|
channel.channel.historyLoading = false;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user