fix scrolling to bottom of chat at graph loading
This commit is contained in:
parent
8bf1394e6f
commit
898cb6da7b
|
|
@ -131,7 +131,7 @@ export class ChatPanel {
|
||||||
<div class="chat-message-icon">
|
<div class="chat-message-icon">
|
||||||
${
|
${
|
||||||
msg.role === 'user'
|
msg.role === 'user'
|
||||||
? `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-user"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>`
|
? `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucude-user"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>`
|
||||||
: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-bot"><path d="M12 8V4H8"></path><rect width="16" height="12" x="4" y="8" rx="2"></rect><path d="M2 14h2"></path><path d="M20 14h2"></path><path d="M15 13v2"></path><path d="M9 13v2"></path></svg>`
|
: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-bot"><path d="M12 8V4H8"></path><rect width="16" height="12" x="4" y="8" rx="2"></rect><path d="M2 14h2"></path><path d="M20 14h2"></path><path d="M15 13v2"></path><path d="M9 13v2"></path></svg>`
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -144,8 +144,23 @@ export class ChatPanel {
|
||||||
)
|
)
|
||||||
.join('');
|
.join('');
|
||||||
|
|
||||||
// Прокручиваем к концу
|
const chatPanelContainer = this.container.querySelector('.llm-agent-chat-panel') as HTMLElement;
|
||||||
historyContainer.scrollTop = historyContainer.scrollHeight;
|
|
||||||
|
// Прокручиваем к последнему сообщению
|
||||||
|
// Обычный `historyContainer.scrollTop = historyContainer.scrollHeight;` не работает
|
||||||
|
if (this.chatHistory.length > 0) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (chatPanelContainer.scrollHeight > chatPanelContainer.clientHeight) {
|
||||||
|
// Используем scrollTop для более точного контроля
|
||||||
|
// Прокручиваем на всю высоту скролла
|
||||||
|
chatPanelContainer.scrollTop = chatPanelContainer.scrollHeight;
|
||||||
|
// Затем отнимаем немного, чтобы создать отступ снизу
|
||||||
|
// 20px - это пример, можно настроить это значение
|
||||||
|
const offset = 20; // Величина отступа от низа
|
||||||
|
chatPanelContainer.scrollTop -= offset;
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,7 @@
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
scroll-margin-bottom: 30px; /* Добавляет отступ в 20px снизу при прокрутке к этому элементу */
|
||||||
}
|
}
|
||||||
|
|
||||||
#send-button {
|
#send-button {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user