feat: the chat's arrow down midway between the answers' right edge and the chat's border, fading in and out
This commit is contained in:
1 parent
46f7f743b3
commit
4fb26a9652
2 files changed
+18
-5
No files matched your search
@@ -25,7 +25,7 @@
|
||||
'<button type="button" class="btn ghost small icon close x ai-close" aria-label="Закрыть"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round"><path d="M18 6 6 18M6 6l12 12"/></svg></button></div>' +
|
||||
'<div class="ai-chats" inert><div class="ai-chats-in"><button type="button" class="ai-chatnew">+ Новый чат</button><div class="ai-chatlist"></div></div></div>' +
|
||||
'<div class="ai-chat-body"><div class="ai-list"><div class="ai-hello"><span class="ai-hello-icon"><svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z"/><path d="M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1"/></svg></span><span class="ai-hello-text">Спросите AI помощника</span></div></div>' +
|
||||
'<button type="button" class="ai-jump" hidden title="К последним сообщениям" aria-label="К последним сообщениям"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5v14M5 12l7 7 7-7"/></svg></button>' +
|
||||
'<button type="button" class="ai-jump" tabindex="-1" title="К последним сообщениям" aria-label="К последним сообщениям"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5v14M5 12l7 7 7-7"/></svg></button>' +
|
||||
'<div class="ai-file-error" role="alert"></div></div>' +
|
||||
'<div class="ai-pills">' +
|
||||
'<button type="button" class="ai-pill" data-mode="agent" aria-pressed="false" title="Сам выполняет шаги один за другим, спрашивая перед каждой командой и записью файла">' +
|
||||
@@ -47,7 +47,19 @@
|
||||
let attachments = [];
|
||||
const importingPaneFiles = new Set();
|
||||
const nearBottom = () => list.scrollHeight - list.scrollTop - list.clientHeight < 80;
|
||||
function updateJump() { jump.hidden = nearBottom() || !isOpen(); }
|
||||
function updateJump() { showJump(!nearBottom() && isOpen()); }
|
||||
// The arrow down fades in and out, midway between the right edge the
|
||||
// answers reach (their max-width, 92% of the list) and the chat's border.
|
||||
function showJump(on) {
|
||||
if (on && !jump.classList.contains('show')) {
|
||||
const body = list.parentNode.getBoundingClientRect(), l = list.getBoundingClientRect(), cs = getComputedStyle(list);
|
||||
const pl = parseFloat(cs.paddingLeft), inner = list.clientWidth - pl - parseFloat(cs.paddingRight);
|
||||
const gap = body.right - (l.left + list.clientLeft + pl + inner * 0.92);
|
||||
jump.style.right = Math.max(2, (gap - jump.offsetWidth) / 2) + 'px';
|
||||
}
|
||||
jump.classList.toggle('show', on);
|
||||
jump.tabIndex = on ? 0 : -1;
|
||||
}
|
||||
list.addEventListener('scroll', updateJump, {passive: true});
|
||||
jump.onclick = () => { list.scrollTo({top: list.scrollHeight, behavior: 'smooth'}); };
|
||||
function scrollIfFollowing(follow) { if (follow) list.scrollTop = list.scrollHeight; updateJump(); }
|
||||
@@ -217,7 +229,7 @@
|
||||
drawChats();
|
||||
list.querySelectorAll('.ai-msg').forEach(m => m.remove());
|
||||
list.scrollTop = 0;
|
||||
jump.hidden = true;
|
||||
showJump(false);
|
||||
hideFileError();
|
||||
q('.ai-hello').hidden = !!id;
|
||||
if (!id) { updateJump(); return; }
|
||||
|
||||
Reference in new issue
Block a user