Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:修复笔记本触摸板点击边事件失效 #1497

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions packages/core/src/view/edge/BaseEdge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type IProps = {
};
export default class BaseEdge extends Component<IProps> {
startTime: number;
mouseUpDrag: boolean;
contextMenuTime: number;
clickTimer: number;
textRef = createRef();
Expand Down Expand Up @@ -324,17 +325,23 @@ export default class BaseEdge extends Component<IProps> {
/**
* 不支持重写
*/
handleMouseDown = (e) => {
handleMouseDown = (e: MouseEvent) => {
e.stopPropagation();
this.startTime = new Date().getTime();
};
/**
* 不支持重写
*/
handleMouseUp = (e: MouseEvent) => {
handleMouseUp = () => {
const { model } = this.props;
this.mouseUpDrag = model.isDragging;
};
/**
* 不支持重写
*/
handleClick = (e: MouseEvent) => {
if (!this.startTime) return;
const time = new Date().getTime() - this.startTime;
if (time > 200) return; // 事件大于200ms,认为是拖拽。
if (this.mouseUpDrag) return; // 如果是拖拽,不触发click事件。
const isRightClick = e.button === 2;
if (isRightClick) return;
// 这里 IE 11不能正确显示
Expand Down Expand Up @@ -425,6 +432,7 @@ export default class BaseEdge extends Component<IProps> {
.join(' ')}
onMouseDown={this.handleMouseDown}
onMouseUp={this.handleMouseUp}
onClick={this.handleClick}
onContextMenu={this.handleContextMenu}
onMouseOver={this.setHoverON}
onMouseEnter={this.setHoverON}
Expand Down