mirror of
https://github.com/ArthurDanjou/artchat.git
synced 2026-02-01 06:29:30 +01:00
feat: improve scroll behavior based on chat message presence
This commit is contained in:
@@ -16,8 +16,21 @@ watch(
|
|||||||
height,
|
height,
|
||||||
async () => {
|
async () => {
|
||||||
await nextTick()
|
await nextTick()
|
||||||
if (lastLang.value === locale.value) {
|
if (lastLang.value === locale.value && parents.value) {
|
||||||
window.scrollTo({ top: parents.value?.scrollHeight, behavior: 'smooth' })
|
const children = parents.value.children
|
||||||
|
if (children.length > 0 && children[children.length - 2]) {
|
||||||
|
const lastChild = children[children.length - 2] as HTMLElement
|
||||||
|
window.scrollTo({
|
||||||
|
top: lastChild.offsetTop - 10,
|
||||||
|
behavior: 'smooth',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
window.scrollTo({
|
||||||
|
top: parents.value.scrollHeight,
|
||||||
|
behavior: 'smooth',
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lastLang.value = locale.value
|
lastLang.value = locale.value
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user