Skip to content

Commit

Permalink
feat: Add dragCache in polygon drag and drop
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerwin-L committed Jul 4, 2022
1 parent 2e5ff62 commit 31a4f5e
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class PolygonOperation extends BasicToolOperation {
initPointList: IPolygonPoint[];
changePointIndex?: number[]; // 用于存储拖拽点 / 边的下标
dragTarget: EDragTarget;

originPolygon?: IPolygonData; // For comparing data before and after drag and drop.
};

private drawingHistory: ActionsHistory; // 用于正在编辑中的历史记录
Expand Down Expand Up @@ -912,6 +914,7 @@ class PolygonOperation extends BasicToolOperation {
dragTarget,
initPointList,
changePointIndex,
originPolygon: this.selectedPolygon,
};

return true;
Expand Down Expand Up @@ -1296,6 +1299,7 @@ class PolygonOperation extends BasicToolOperation {

if (this.dragInfo && this.dragStatus === EDragStatus.Move) {
// 拖拽停止
const { originPolygon } = this.dragInfo;
this.dragInfo = undefined;
this.dragStatus = EDragStatus.Wait;
this.history.pushHistory(this.polygonList);
Expand All @@ -1304,7 +1308,7 @@ class PolygonOperation extends BasicToolOperation {
this.emit('updateResult');

// Emit polygon.
this.emit('updatePolygonByDrag', this.selectedPolygon);
this.emit('updatePolygonByDrag', { newPolygon: this.selectedPolygon, originPolygon });
return;
}

Expand Down

0 comments on commit 31a4f5e

Please sign in to comment.