Skip to content

Commit

Permalink
fixed: Fixed an issue where the right mouse button controlled the Cha…
Browse files Browse the repository at this point in the history
…t icon
  • Loading branch information
ZhaoJiSen authored and BaiJiangJie committed Dec 25, 2024
1 parent e86f2fc commit 5aca8d0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app/elements/chat/chat.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ export class ElementChatComponent implements OnInit, OnDestroy {

elements.forEach(element => {
element.addEventListener('mousedown', (event: MouseEvent) => {
if (event.button !== 0) {
return;
}

event.stopPropagation();
event.preventDefault();
const offsetY = dragBox.getBoundingClientRect().top;
Expand All @@ -70,6 +74,7 @@ export class ElementChatComponent implements OnInit, OnDestroy {
clientOffset.clientY = event.clientY;
this.isLongPress = false;

// @ts-ignore
this.longPressTimeout = setTimeout(() => {
this.isLongPress = true;
document.onmousemove = (ev: MouseEvent) => {
Expand All @@ -89,14 +94,14 @@ export class ElementChatComponent implements OnInit, OnDestroy {
ev.preventDefault();
ev.stopPropagation();
};
}, 300); // 300ms 作为长按检测时间
}, 300);

document.onmouseup = () => {
document.onmousemove = null;
document.onmouseup = null;

if (!this.isLongPress) {
clearTimeout(this.longPressTimeout); // 确保清除长按检测
clearTimeout(this.longPressTimeout);
this.isShow = !this.isShow;
}

Expand Down

0 comments on commit 5aca8d0

Please sign in to comment.