Spaces:
Running
Running
fix typing animation's location issue in the chat
Browse files- index.html +10 -8
- script.js +23 -3
index.html
CHANGED
|
@@ -78,15 +78,17 @@
|
|
| 78 |
</div>
|
| 79 |
</div>
|
| 80 |
</div>
|
| 81 |
-
<div id="typingIndicator" class="hidden flex items-start
|
| 82 |
-
<div class="w-
|
| 83 |
-
<i data-feather="cpu" class="w-4 h-4 text-zinc-
|
| 84 |
</div>
|
| 85 |
-
<div class="
|
| 86 |
-
<div class="
|
| 87 |
-
<
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
| 90 |
</div>
|
| 91 |
</div>
|
| 92 |
</div>
|
|
|
|
| 78 |
</div>
|
| 79 |
</div>
|
| 80 |
</div>
|
| 81 |
+
<div id="typingIndicator" class="hidden flex items-start gap-3 message-slide-in group">
|
| 82 |
+
<div class="w-9 h-9 rounded-xl bg-gradient-to-br from-zinc-800 to-zinc-900 flex items-center justify-center flex-shrink-0 ring-1 ring-zinc-800/50 group-hover:ring-zinc-700/50 transition-all duration-200">
|
| 83 |
+
<i data-feather="cpu" class="w-4.5 h-4.5 text-zinc-300"></i>
|
| 84 |
</div>
|
| 85 |
+
<div class="flex-1 max-w-4xl">
|
| 86 |
+
<div class="bg-zinc-900/60 backdrop-blur-sm rounded-2xl p-4 border border-zinc-800/50 hover:border-zinc-700/50 transition-all duration-200">
|
| 87 |
+
<div class="typing-indicator flex space-x-1">
|
| 88 |
+
<span class="w-2 h-2 bg-zinc-400 rounded-full"></span>
|
| 89 |
+
<span class="w-2 h-2 bg-zinc-400 rounded-full"></span>
|
| 90 |
+
<span class="w-2 h-2 bg-zinc-400 rounded-full"></span>
|
| 91 |
+
</div>
|
| 92 |
</div>
|
| 93 |
</div>
|
| 94 |
</div>
|
script.js
CHANGED
|
@@ -328,15 +328,35 @@ function autoResize(textarea) {
|
|
| 328 |
textarea.style.height = 'auto';
|
| 329 |
textarea.style.height = Math.min(textarea.scrollHeight, 120) + 'px';
|
| 330 |
}
|
| 331 |
-
|
| 332 |
function showTypingIndicator() {
|
| 333 |
-
document.getElementById('typingIndicator')
|
| 334 |
const chatContainer = document.getElementById('chatContainer');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
chatContainer.scrollTop = chatContainer.scrollHeight;
|
|
|
|
|
|
|
|
|
|
| 336 |
}
|
| 337 |
|
| 338 |
function hideTypingIndicator() {
|
| 339 |
-
document.getElementById('typingIndicator')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 340 |
}
|
| 341 |
function toggleChatMode() {
|
| 342 |
isCompactMode = !isCompactMode;
|
|
|
|
| 328 |
textarea.style.height = 'auto';
|
| 329 |
textarea.style.height = Math.min(textarea.scrollHeight, 120) + 'px';
|
| 330 |
}
|
|
|
|
| 331 |
function showTypingIndicator() {
|
| 332 |
+
const typingIndicator = document.getElementById('typingIndicator');
|
| 333 |
const chatContainer = document.getElementById('chatContainer');
|
| 334 |
+
|
| 335 |
+
// Remove any existing typing indicator
|
| 336 |
+
if (typingIndicator.parentNode === chatContainer) {
|
| 337 |
+
typingIndicator.remove();
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
// Add the typing indicator at the end of chat container
|
| 341 |
+
chatContainer.appendChild(typingIndicator);
|
| 342 |
+
typingIndicator.classList.remove('hidden');
|
| 343 |
+
typingIndicator.classList.add('message-slide-in');
|
| 344 |
+
|
| 345 |
+
// Scroll to bottom to show the indicator
|
| 346 |
chatContainer.scrollTop = chatContainer.scrollHeight;
|
| 347 |
+
|
| 348 |
+
// Re-initialize feather icons for the typing indicator
|
| 349 |
+
feather.replace();
|
| 350 |
}
|
| 351 |
|
| 352 |
function hideTypingIndicator() {
|
| 353 |
+
const typingIndicator = document.getElementById('typingIndicator');
|
| 354 |
+
typingIndicator.classList.add('hidden');
|
| 355 |
+
|
| 356 |
+
// Remove the typing indicator from DOM when hidden
|
| 357 |
+
if (typingIndicator.parentNode) {
|
| 358 |
+
typingIndicator.remove();
|
| 359 |
+
}
|
| 360 |
}
|
| 361 |
function toggleChatMode() {
|
| 362 |
isCompactMode = !isCompactMode;
|