Skip to content

Commit

Permalink
fix: 修复折线绘制后只选中第一个点的BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
Yan Heng committed Jul 25, 2023
1 parent 922d65c commit 09288cb
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions packages/core/src/tools/polyline-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,29 @@ class PolylineTool implements Tool {
if (!lastPoint || !lastPoint.eq(app.pointer)) {
this.points.push(app.pointer);
}
if (!this.polyline) {
this.polyline = new Polyline(this.points, {
fill: 'transparent',
stroke: 'black',
strokeWidth: 2,
});
app.canvas.add(this.polyline);
} else {
this.polyline.set({ points: this.points });
if (this.polyline) {
app.canvas.remove(this.polyline);
}
this.polyline = new Polyline(this.points, {
fill: 'transparent',
stroke: 'black',
strokeWidth: 2,
});
app.canvas.add(this.polyline);
}

public onMouseMove({ app }: AppMouseEvent): void {
if (!this.polyline) {
return;
}
this.polyline.set({ points: this.points.concat(app.pointer) });
app.render(); // Call render after updating the polyline
app.render();
}

public onMouseDoubleClick({ app }: AppMouseEvent) {
app.setTool(selectTool);

if (this.polyline) {
console.log('====>', this.polyline.points, this.points);

app.canvas.setActiveObject(this.polyline);
}

Expand Down

0 comments on commit 09288cb

Please sign in to comment.