Skip to content

Commit

Permalink
feat:事件委托,触发流程备注
Browse files Browse the repository at this point in the history
  • Loading branch information
yelikang committed Aug 20, 2024
1 parent b85ca7f commit dc6ca1a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/x6/src/graph/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export class GraphView extends View {

delegateEvents() {
// 委托监听this.container dom事件上的交互事件;在对应的handler上再去触发graph上的事件
// 1. GraphView中将ctor.events事件都绑定在this.container上,回调事件根据配置,指向GraphView上具体的函数
// 2.this.container中的DOM事件触发之后,根据事件信息,找到对应的CellView子类,然后触发CellView上的事件
// 3.CellView中的notify,会触发this.graph.trigger事件,从而将事件传递给graph;业务层如果监听了graph上的事件(例如 this.graph.on('cell:added'))),也会收到事件
const ctor = this.constructor as typeof GraphView
super.delegateEvents(ctor.events)
return this
Expand Down

0 comments on commit dc6ca1a

Please sign in to comment.