Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading