Add chat scroll to bottom when opening it

This commit is contained in:
ClemDee
2019-05-29 12:22:18 +02:00
parent 62eb623f49
commit bfba5ff33b
2 changed files with 13 additions and 5 deletions

View File

@@ -197,6 +197,11 @@ define([
var getChat = function (id) {
return $messages.find(dataQuery(id));
};
var scrollChatToBottom = function () {
var $messagebox = $('.cp-app-contacts-messages');
$messagebox.scrollTop($messagebox[0].scrollHeight);
};
var normalizeLabels = function ($messagebox) {
$messagebox.find('div.cp-app-contacts-message').toArray().reduce(function (a, b) {
@@ -364,10 +369,7 @@ define([
input.value = '';
sending = false;
debug('sent successfully');
var $messagebox = $(messages);
var height = $messagebox[0].scrollHeight;
$messagebox.scrollTop(height);
scrollChatToBottom();
});
};
@@ -584,7 +586,7 @@ define([
$messagebox.append(el_message);
if (shouldScroll) {
$messagebox.scrollTop($messagebox[0].scrollHeight);
scrollChatToBottom();
}
normalizeLabels($messagebox);
reorderRooms();