Skip to content

Commit 5aca8d0

Browse files
ZhaoJiSenBaiJiangJie
authored andcommitted
fixed: Fixed an issue where the right mouse button controlled the Chat icon
1 parent e86f2fc commit 5aca8d0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/app/elements/chat/chat.component.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ export class ElementChatComponent implements OnInit, OnDestroy {
6262

6363
elements.forEach(element => {
6464
element.addEventListener('mousedown', (event: MouseEvent) => {
65+
if (event.button !== 0) {
66+
return;
67+
}
68+
6569
event.stopPropagation();
6670
event.preventDefault();
6771
const offsetY = dragBox.getBoundingClientRect().top;
@@ -70,6 +74,7 @@ export class ElementChatComponent implements OnInit, OnDestroy {
7074
clientOffset.clientY = event.clientY;
7175
this.isLongPress = false;
7276

77+
// @ts-ignore
7378
this.longPressTimeout = setTimeout(() => {
7479
this.isLongPress = true;
7580
document.onmousemove = (ev: MouseEvent) => {
@@ -89,14 +94,14 @@ export class ElementChatComponent implements OnInit, OnDestroy {
8994
ev.preventDefault();
9095
ev.stopPropagation();
9196
};
92-
}, 300); // 300ms 作为长按检测时间
97+
}, 300);
9398

9499
document.onmouseup = () => {
95100
document.onmousemove = null;
96101
document.onmouseup = null;
97102

98103
if (!this.isLongPress) {
99-
clearTimeout(this.longPressTimeout); // 确保清除长按检测
104+
clearTimeout(this.longPressTimeout);
100105
this.isShow = !this.isShow;
101106
}
102107

0 commit comments

Comments
 (0)