fix: 修复【应用】浮窗模式嵌入第三方,开启可拖动位置,手机上无法拖动 (#893)

This commit is contained in:
shaohuzhang1 2024-07-29 18:09:22 +08:00 committed by GitHub
parent 336a0dfebe
commit 8719f71efd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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