Merge pull request #2107 from thelounge/xpaw/correct-scroller

Always correctly trigger sticky scroll on .chat container
This commit is contained in:
Jérémie Astori 2018-02-23 19:38:57 -05:00 committed by GitHub
commit f18a7b2fe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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.find(".show-more").addClass("show");
} }
container.trigger("keepToBottom"); container.parent().trigger("keepToBottom");
} }
} else { } else {
newChannels.push(channel); newChannels.push(channel);

View File

@ -55,7 +55,7 @@ function appendPreview(preview, msg, template) {
return; return;
} }
const container = msg.closest(".messages"); const container = msg.closest(".chat");
const channelId = container.closest(".chan").data("id") || -1; const channelId = container.closest(".chan").data("id") || -1;
const activeChannelId = chat.find(".chan.active").data("id") || -2; 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 container = channel.find(".messages");
const activeChannelId = chat.find(".chan.active").data("id"); const activeChannelId = chat.find(".chan.active").data("id");
@ -64,7 +65,7 @@ function processReceivedMessage(data) {
); );
if (activeChannelId === targetId) { if (activeChannelId === targetId) {
container.trigger("keepToBottom"); scrollContainer.trigger("keepToBottom");
} }
notifyMessage(targetId, channel, data); notifyMessage(targetId, channel, data);
@ -91,7 +92,7 @@ function processReceivedMessage(data) {
if (activeChannelId !== targetId) { if (activeChannelId !== targetId) {
// If message arrives in non active channel, keep only 100 messages // If message arrives in non active channel, keep only 100 messages
messageLimit = 100; 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 // If message arrives in active channel, keep 500 messages if scroll is currently at the bottom
messageLimit = 500; messageLimit = 500;
} }