2
0

🚸 (bubble) Add swipe gesture to close preview…

Closes #1388
This commit is contained in:
Baptiste Arnaud
2024-03-26 19:26:39 +01:00
parent 798e94a8b3
commit 1f158e78c9
4 changed files with 26 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@typebot.io/js",
"version": "0.2.56",
"version": "0.2.57",
"description": "Javascript library to display typebots on your website",
"type": "module",
"main": "dist/index.js",

View File

@ -20,6 +20,27 @@ const defaultTextColor = '#303235'
export const PreviewMessage = (props: PreviewMessageProps) => {
const [isPreviewMessageHovered, setIsPreviewMessageHovered] =
createSignal(false)
const [touchStartPosition, setTouchStartPosition] = createSignal({
x: 0,
y: 0,
})
const handleTouchStart = (e: TouchEvent) => {
setTouchStartPosition({ x: e.touches[0].clientX, y: e.touches[0].clientY })
}
const handleTouchEnd = (e: TouchEvent) => {
const x = e.changedTouches[0].clientX
const y = e.changedTouches[0].clientY
if (
Math.abs(x - touchStartPosition().x) > 10 ||
y - touchStartPosition().y > 10
)
props.onCloseClick()
setTouchStartPosition({ x: 0, y: 0 })
}
return (
<div
@ -38,6 +59,8 @@ export const PreviewMessage = (props: PreviewMessageProps) => {
}}
onMouseEnter={() => setIsPreviewMessageHovered(true)}
onMouseLeave={() => setIsPreviewMessageHovered(false)}
onTouchStart={handleTouchStart}
onTouchEnd={handleTouchEnd}
>
<CloseButton
isHovered={isPreviewMessageHovered()}

View File

@ -1,6 +1,6 @@
{
"name": "@typebot.io/nextjs",
"version": "0.2.56",
"version": "0.2.57",
"description": "Convenient library to display typebots on your Next.js website",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View File

@ -1,6 +1,6 @@
{
"name": "@typebot.io/react",
"version": "0.2.56",
"version": "0.2.57",
"description": "Convenient library to display typebots on your React app",
"main": "dist/index.js",
"types": "dist/index.d.ts",