🐛 (bot) Fix double callback on video and audio bubble
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/js",
|
"name": "@typebot.io/js",
|
||||||
"version": "0.0.75",
|
"version": "0.0.76",
|
||||||
"description": "Javascript library to display typebots on your website",
|
"description": "Javascript library to display typebots on your website",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|||||||
@@ -25,17 +25,19 @@ export const AudioBubble = (props: Props) => {
|
|||||||
props.onTransitionEnd(ref?.offsetTop)
|
props.onTransitionEnd(ref?.offsetTop)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onCanPlay = () => {
|
||||||
|
clearTimeout(typingTimeout)
|
||||||
|
setIsTyping(false)
|
||||||
|
setTimeout(autoPlay, showAnimationDuration)
|
||||||
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
typingTimeout = setTimeout(() => {
|
typingTimeout = setTimeout(() => {
|
||||||
|
if (audioElement) audioElement.removeEventListener('canplay', onCanPlay)
|
||||||
setIsTyping(false)
|
setIsTyping(false)
|
||||||
setTimeout(autoPlay, showAnimationDuration)
|
setTimeout(autoPlay, showAnimationDuration)
|
||||||
}, defaultTypingDuration)
|
}, defaultTypingDuration)
|
||||||
if (audioElement)
|
if (audioElement) audioElement.addEventListener('canplay', onCanPlay)
|
||||||
audioElement.oncanplay = () => {
|
|
||||||
clearTimeout(typingTimeout)
|
|
||||||
setIsTyping(false)
|
|
||||||
setTimeout(autoPlay, showAnimationDuration)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
onCleanup(() => {
|
onCleanup(() => {
|
||||||
|
|||||||
@@ -27,21 +27,23 @@ export const VideoBubble = (props: Props) => {
|
|||||||
props.onTransitionEnd(ref?.offsetTop)
|
props.onTransitionEnd(ref?.offsetTop)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onCanPlay = () => {
|
||||||
|
clearTimeout(typingTimeout)
|
||||||
|
setIsTyping(false)
|
||||||
|
setTimeout(autoPlay, showAnimationDuration)
|
||||||
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
console.log(videoElement)
|
console.log(videoElement)
|
||||||
typingTimeout = setTimeout(
|
typingTimeout = setTimeout(
|
||||||
() => {
|
() => {
|
||||||
|
if (videoElement) videoElement.removeEventListener('canplay', onCanPlay)
|
||||||
setIsTyping(false)
|
setIsTyping(false)
|
||||||
setTimeout(autoPlay, showAnimationDuration)
|
setTimeout(autoPlay, showAnimationDuration)
|
||||||
},
|
},
|
||||||
videoElement ? defaultTypingDuration : 2000
|
videoElement ? defaultTypingDuration : 2000
|
||||||
)
|
)
|
||||||
if (videoElement)
|
if (videoElement) videoElement.addEventListener('canplay', onCanPlay)
|
||||||
videoElement.oncanplay = () => {
|
|
||||||
clearTimeout(typingTimeout)
|
|
||||||
setIsTyping(false)
|
|
||||||
setTimeout(autoPlay, showAnimationDuration)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
onCleanup(() => {
|
onCleanup(() => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/react",
|
"name": "@typebot.io/react",
|
||||||
"version": "0.0.75",
|
"version": "0.0.76",
|
||||||
"description": "React library to display typebots on your website",
|
"description": "React library to display typebots on your website",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user