antvis / g6-editor

534 stars 172 forks source link

请问如何获取所有支持的事件名? #103

Open lianchi opened 5 years ago

lianchi commented 5 years ago
import G6Editor from '@antv/g6-editor'

const editor = new G6Editor()
const flow = new G6Editor.Flow()

请问 editorflow 支持的所有事件都有哪些?

目前我的需求: 从左边 itempanel 面板拖拽某个元素至右侧编辑区时(该元素的 id 被固定),判断当前编辑区是否存在 id 一样的元素,若存在,则弹框告警,同时中止拖拽。

所以我想是否存在「以拖拽方式新增元素」的事件,可以被我捕获到。 另外,目前 g6-editor 源码里已有类似「防重复 id」的处理,它会浏览器控制台触发 error。换个角度说,我是否也可以用 try catch 捕获到 error 报错,然后插入我的弹框逻辑?

guozhaolong commented 5 years ago

我看它源码里添加item结束时有graph.emit('aftereadditem', { type, model }); 你可以试试在你的代码里graph.on('aftereadditem',xxx),在xxx里写判断和移除的代码

papibabi commented 5 years ago

在哪里看的源码啊

guozhaolong commented 5 years ago

在哪里看的源码啊

g6的源码,github上有

junob commented 5 years ago

楼主实现了吗,如何可以中止拖拽