Skip to content

Commit

Permalink
feat: 新增update更新对象方法
Browse files Browse the repository at this point in the history
  • Loading branch information
JessYan0913 committed Aug 2, 2023
1 parent 3fdd318 commit 7a37a49
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/core/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,18 @@ export class App extends BaseService<EventArgs> {
this.render();
}

public _update(): void {}
public update(...nodes: KonvaNode[]): void {
this._update(...nodes);
this.emit('node:updated', { nodes });
}

public _update(...nodes: KonvaNode[]): void {
nodes.forEach((node) => {
const originNode = this.getNodeById(node.attrs.id);
originNode?.setAttrs(node.attrs);
});
this.render();
}

public getNodeById(id: string): KonvaNode | undefined {
return this.getNodes((node) => node.id() === id)?.[0];
Expand Down

0 comments on commit 7a37a49

Please sign in to comment.