Always correctly trigger sticky scroll on .chat container

`.chat` has the overflow on it, and not `.messages` so stuff like scrollTop only works on `.chat`
This commit is contained in:
Pavel Djundik 2018-02-23 18:21:42 +02:00
parent 5bac385a75
commit 63828b95e0
3 changed files with 5 additions and 4 deletions

View file

@ -217,7 +217,7 @@ function renderNetworks(data, singleNetwork) {
container.find(".show-more").addClass("show");
}
container.trigger("keepToBottom");
container.parent().trigger("keepToBottom");
}
} else {
newChannels.push(channel);

View file

@ -55,7 +55,7 @@ function appendPreview(preview, msg, template) {
return;
}
const container = msg.closest(".messages");
const container = msg.closest(".chat");
const channelId = container.closest(".chan").data("id") || -1;
const activeChannelId = chat.find(".chan.active").data("id") || -2;

View file

@ -48,6 +48,7 @@ function processReceivedMessage(data) {
}
}
const scrollContainer = channel.find(".chat");
const container = channel.find(".messages");
const activeChannelId = chat.find(".chan.active").data("id");
@ -64,7 +65,7 @@ function processReceivedMessage(data) {
);
if (activeChannelId === targetId) {
container.trigger("keepToBottom");
scrollContainer.trigger("keepToBottom");
}
notifyMessage(targetId, channel, data);
@ -91,7 +92,7 @@ function processReceivedMessage(data) {
if (activeChannelId !== targetId) {
// If message arrives in non active channel, keep only 100 messages
messageLimit = 100;
} else if (container.isScrollBottom()) {
} else if (scrollContainer.isScrollBottom()) {
// If message arrives in active channel, keep 500 messages if scroll is currently at the bottom
messageLimit = 500;
}