This commit is contained in:
Timothy Jaeryang Baek
2024-12-20 14:44:12 -08:00
parent 37ce88e744
commit ad5cc9d79e
2 changed files with 15 additions and 5 deletions

View File

@@ -79,9 +79,14 @@
if (data.choices && data.choices[0]?.delta?.content) {
responseContent += data.choices[0].delta.content;
// Scroll to bottom
// Scroll to bottom only if the scroll is at the bottom give 50px buffer
const responseContainer = document.getElementById('response-container');
responseContainer.scrollTop = responseContainer.scrollHeight;
if (
responseContainer.scrollHeight - responseContainer.clientHeight <=
responseContainer.scrollTop + 50
) {
responseContainer.scrollTop = responseContainer.scrollHeight;
}
}
} catch (e) {
console.error(e);
@@ -152,7 +157,12 @@
// Scroll to bottom
const responseContainer = document.getElementById('response-container');
responseContainer.scrollTop = responseContainer.scrollHeight;
if (
responseContainer.scrollHeight - responseContainer.clientHeight <=
responseContainer.scrollTop + 50
) {
responseContainer.scrollTop = responseContainer.scrollHeight;
}
}
} catch (e) {
console.error(e);