feat(user_msg): auto scroll to bottom after enter or send msg

This commit is contained in:
Baoshuo Ren 2023-01-16 16:50:58 +08:00
parent 99e9a839af
commit d6ac737a11
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -150,7 +150,7 @@ if (isset($_POST['user_msg'])) {
<button id="goBack" class="btn-close position-absolute" aria-label="关闭对话"></button> <button id="goBack" class="btn-close position-absolute" aria-label="关闭对话"></button>
<div id="conversation-name" class="text-center"></div> <div id="conversation-name" class="text-center"></div>
</div> </div>
<div class="card-body overflow-auto"> <div class="card-body overflow-auto" id="history-list-container">
<div id="history-list" style="min-height: 200px;"></div> <div id="history-list" style="min-height: 200px;"></div>
</div> </div>
<div class="card-footer bg-transparent"> <div class="card-footer bg-transparent">
@ -376,6 +376,7 @@ if (isset($_POST['user_msg'])) {
}, REFRESH_INTERVAL); }, REFRESH_INTERVAL);
$('#history').show(); $('#history').show();
$('#conversations').addClass('d-none d-md-block') $('#conversations').addClass('d-none d-md-block')
$("#history-list-container").scrollTop($("#history-list").height());
$('#input-message').unbind('keydown').keydown(function(e) { $('#input-message').unbind('keydown').keydown(function(e) {
if (e.keyCode == 13 && e.ctrlKey) { if (e.keyCode == 13 && e.ctrlKey) {
$('#message-submit').click(); $('#message-submit').click();
@ -386,6 +387,7 @@ if (isset($_POST['user_msg'])) {
page = 1; page = 1;
changeAble = refreshHistory(conversationName, page); changeAble = refreshHistory(conversationName, page);
refreshConversations(); refreshConversations();
$("#history-list-container").scrollTop($("#history-list").height());
return false; return false;
}); });
$('#goBack').unbind("click").click(function() { $('#goBack').unbind("click").click(function() {