diff --git a/packages/embeds/js/package.json b/packages/embeds/js/package.json index d350c5d77..5d321f59e 100644 --- a/packages/embeds/js/package.json +++ b/packages/embeds/js/package.json @@ -1,6 +1,6 @@ { "name": "@typebot.io/js", - "version": "0.1.12", + "version": "0.1.13", "description": "Javascript library to display typebots on your website", "type": "module", "main": "dist/index.js", diff --git a/packages/embeds/js/src/assets/index.css b/packages/embeds/js/src/assets/index.css index 46cbf9a29..c9a31b743 100644 --- a/packages/embeds/js/src/assets/index.css +++ b/packages/embeds/js/src/assets/index.css @@ -76,10 +76,10 @@ @keyframes chatBubbles { 0% { - transform: translateY(0); + transform: translateY(2.5); } 50% { - transform: translateY(-5px); + transform: translateY(-2.5px); } 100% { transform: translateY(0); diff --git a/packages/embeds/js/src/features/blocks/bubbles/audio/components/AudioBubble.tsx b/packages/embeds/js/src/features/blocks/bubbles/audio/components/AudioBubble.tsx index e1fd72a45..f9e5616a7 100644 --- a/packages/embeds/js/src/features/blocks/bubbles/audio/components/AudioBubble.tsx +++ b/packages/embeds/js/src/features/blocks/bubbles/audio/components/AudioBubble.tsx @@ -1,4 +1,5 @@ import { TypingBubble } from '@/components' +import { isMobile } from '@/utils/isMobileSignal' import type { AudioBubbleContent } from '@typebot.io/schemas' import { createSignal, onCleanup, onMount } from 'solid-js' @@ -8,7 +9,7 @@ type Props = { } const showAnimationDuration = 400 -const typingDuration = 500 +const typingDuration = 100 let typingTimeout: NodeJS.Timeout @@ -18,29 +19,16 @@ export const AudioBubble = (props: Props) => { let audioElement: HTMLAudioElement | undefined const [isTyping, setIsTyping] = createSignal(true) - const endTyping = () => { - if (isPlayed) return - isPlayed = true - setIsTyping(false) - setTimeout( - () => props.onTransitionEnd(ref?.offsetTop), - showAnimationDuration - ) - } - onMount(() => { - typingTimeout = setTimeout(endTyping, typingDuration) - audioElement?.addEventListener( - 'canplay', - () => { - clearTimeout(typingTimeout) - audioElement - ?.play() - .catch((e) => console.warn("Couldn't autoplay audio", e)) - endTyping() - }, - { once: true } - ) + typingTimeout = setTimeout(() => { + if (isPlayed) return + isPlayed = true + setIsTyping(false) + setTimeout( + () => props.onTransitionEnd(ref?.offsetTop), + showAnimationDuration + ) + }, typingDuration) }) onCleanup(() => { @@ -63,11 +51,14 @@ export const AudioBubble = (props: Props) => {