From 8719f71efd39d4798b78673a368f69838af0445d Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Mon, 29 Jul 2024 18:09:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E3=80=90=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E3=80=91=E6=B5=AE=E7=AA=97=E6=A8=A1=E5=BC=8F=E5=B5=8C?= =?UTF-8?q?=E5=85=A5=E7=AC=AC=E4=B8=89=E6=96=B9=EF=BC=8C=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E5=8F=AF=E6=8B=96=E5=8A=A8=E4=BD=8D=E7=BD=AE=EF=BC=8C=E6=89=8B?= =?UTF-8?q?=E6=9C=BA=E4=B8=8A=E6=97=A0=E6=B3=95=E6=8B=96=E5=8A=A8=20(#893)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/application/template/embed.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/application/template/embed.js b/apps/application/template/embed.js index 1b7b801ad..028a642b4 100644 --- a/apps/application/template/embed.js +++ b/apps/application/template/embed.js @@ -87,13 +87,20 @@ const initChat=(root)=>{ closeviewport.classList.remove('maxkb-viewportnone') } } - const drag=(e)=>{ - chat_button.style.top=(e.y-25)+'px' - chat_button.style.left=(e.x-25)+'px' - } + const drag=(e)=>{ + if (['touchmove','touchstart'].includes(e.type)) { + chat_button.style.top=(e.touches[0].clientY-25)+'px' + chat_button.style.left=(e.touches[0].clientX-25)+'px' + } else { + chat_button.style.top=(e.y-25)+'px' + chat_button.style.left=(e.x-25)+'px' + } + } if({{is_draggable}}){ chat_button.addEventListener("drag",drag) chat_button.addEventListener("dragend",drag) + chat_button.addEventListener("touchstart",drag) + chat_button.addEventListener("touchmove",drag) } viewport.onclick=viewport_func closeviewport.onclick=viewport_func