Skip to content

Commit c58a536

Browse files
update auto scroll
1 parent 83645ba commit c58a536

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

assets/js/core/core-ai.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ setupVoiceRecognition(micBtn, async (transcript) => {
4040
const wrapper = document.createElement("div");
4141
wrapper.innerHTML = cardHTML;
4242
messages.appendChild(wrapper);
43-
scrollToBottom();
43+
setTimeout(() => scrollToBottom(), 0);
4444
return;
4545
}
4646

@@ -134,8 +134,10 @@ setupVoiceRecognition(micBtn, async (transcript) => {
134134
const cardBlock = document.createElement("div");
135135
cardBlock.innerHTML = cards;
136136
messages.appendChild(cardBlock);
137+
setTimeout(() => scrollToBottom(), 50);
137138
} else {
138139
handleAIReply(reply);
140+
setTimeout(() => scrollToBottom(), 50);
139141
}
140142

141143
} catch (err) {
@@ -149,13 +151,16 @@ setupVoiceRecognition(micBtn, async (transcript) => {
149151
speakWithTTS(text);
150152
renderVoiceMessage("bot", null, "Lyra mengirim voice note");
151153
resetVoiceFlag();
154+
setTimeout(() => scrollToBottom(), 50);
152155
return;
153156
}
154157
if (isVoiceMode) {
155158
speakWithTTS(text);
156159
renderVoiceMessage("bot", null, "Lyra mengirim voice note");
160+
setTimeout(() => scrollToBottom(), 50);
157161
} else {
158162
addMessage("bot", text);
163+
setTimeout(() => scrollToBottom(), 50);
159164
}
160165
}
161166

0 commit comments

Comments
 (0)