Skip to content

Commit

Permalink
update: 更新mouseService
Browse files Browse the repository at this point in the history
  • Loading branch information
JessYan0913 committed Jul 27, 2023
1 parent a237a2a commit 2358d24
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions packages/core/src/services/mouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type IMouseEvent = TPointerEventInfo<TPointerEvent>;
type IMouseEventHandler = (event: IMouseEvent) => void;

export class MouseService extends Service {
private event?: TPointerEvent;
private event?: IMouseEvent;
private targets: Object[];
private handleMouseDown: IMouseEventHandler;
private handleMouseUp: IMouseEventHandler;
Expand Down Expand Up @@ -39,8 +39,7 @@ export class MouseService extends Service {
if (!this.event) {
return new Point(0, 0);
}
const { x, y } = this.app.canvas.getPointer(this.event);
return new Point(x, y);
return this.event.pointer;
}

public toGlobal(point: Point): Point {
Expand All @@ -61,7 +60,7 @@ export class MouseService extends Service {
}

private onMouseDown(event: IMouseEvent): void {
this.event = event.e;
this.event = event;
if (!this.app.currentTool) {
return;
}
Expand All @@ -75,7 +74,7 @@ export class MouseService extends Service {
}

private onMouseUp(event: IMouseEvent): void {
this.event = event.e;
this.event = event;
if (!this.app.currentTool) {
return;
}
Expand All @@ -89,7 +88,7 @@ export class MouseService extends Service {
}

private onMouseMove(event: IMouseEvent): void {
this.event = event.e;
this.event = event;
if (!this.app.currentTool) {
return;
}
Expand All @@ -103,7 +102,7 @@ export class MouseService extends Service {
}

private onMouseDoubleClick(event: IMouseEvent): void {
this.event = event.e;
this.event = event;
if (!this.app.currentTool) {
return;
}
Expand All @@ -113,11 +112,11 @@ export class MouseService extends Service {
}

private onMouseOver(event: IMouseEvent): void {
this.event = event.e;
this.event = event;
}

private onMouseOut(event: IMouseEvent): void {
this.event = event.e;
this.event = event;
}

public dispose(): void {
Expand Down

0 comments on commit 2358d24

Please sign in to comment.