Skip to content

Commit 7a37a49

Browse files
committed
feat: 新增update更新对象方法
1 parent 3fdd318 commit 7a37a49

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/core/src/app.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,18 @@ export class App extends BaseService<EventArgs> {
9898
this.render();
9999
}
100100

101-
public _update(): void {}
101+
public update(...nodes: KonvaNode[]): void {
102+
this._update(...nodes);
103+
this.emit('node:updated', { nodes });
104+
}
105+
106+
public _update(...nodes: KonvaNode[]): void {
107+
nodes.forEach((node) => {
108+
const originNode = this.getNodeById(node.attrs.id);
109+
originNode?.setAttrs(node.attrs);
110+
});
111+
this.render();
112+
}
102113

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

0 commit comments

Comments
 (0)