🚸 Improve chat auto scroll

Instead of scrolling all the way to the bottom on each bubble, now we scroll to the top of the last bubble

Closes #486
This commit is contained in:
Baptiste Arnaud
2023-05-12 16:37:04 -04:00
parent df8a406513
commit a3fb098dfa
10 changed files with 33 additions and 33 deletions

View File

@@ -4,7 +4,7 @@ import { createSignal, onCleanup, onMount } from 'solid-js'
type Props = {
content: EmbedBubbleContent
onTransitionEnd: () => void
onTransitionEnd: (offsetTop?: number) => void
}
let typingTimeout: NodeJS.Timeout
@@ -12,13 +12,14 @@ let typingTimeout: NodeJS.Timeout
export const showAnimationDuration = 400
export const EmbedBubble = (props: Props) => {
let ref: HTMLDivElement | undefined
const [isTyping, setIsTyping] = createSignal(true)
onMount(() => {
typingTimeout = setTimeout(() => {
setIsTyping(false)
setTimeout(() => {
props.onTransitionEnd()
props.onTransitionEnd(ref?.offsetTop)
}, showAnimationDuration)
}, 2000)
})
@@ -28,7 +29,7 @@ export const EmbedBubble = (props: Props) => {
})
return (
<div class="flex flex-col w-full animate-fade-in">
<div class="flex flex-col w-full animate-fade-in" ref={ref}>
<div class="flex w-full items-center">
<div
class={'flex relative z-10 items-start typebot-host-bubble w-full'}