double click fold & unfold

This commit is contained in:
zhandouxiaojiji committed 2020-10-19 20:42:56 +08:00
1 parent d2b0584c24
commit 0093bf961e
2 files changed
+22 -9

No files matched your search

+22 -7
View File
@@ -1,7 +1,10 @@
import * as React from 'react';
import GGEditor, { Mind, RegisterNode, setAnchorPointsState } from 'gg-editor';
import GGEditor, { Mind, RegisterNode, constants, CommandManager } from 'gg-editor';
import { INode } from '@antv/g6/lib/interface/item';
import { MindData, Graph, GraphEvent } from 'gg-editor/lib/common/interfaces';
const { EditorCommand } = constants
const data: MindData = {
id: "1",
label: 'Central Topic111',
@@ -27,21 +30,32 @@ interface BehaviorTreeProps {
class BehaviorTree extends React.Component<BehaviorTreeProps> {
graph: Graph;
mind: Mind;
componentDidMount() {
}
initGraph(graph: Graph) {
const { onSelectNode } = this.props;
graph.on('click', (ev: GraphEvent) => {
if (!ev.item) {
const item = ev.item;
if (!item) {
onSelectNode(null);
} else if (ev.item.getType() == "node") {
onSelectNode(ev.item as INode);
} else if (item.getType() == "node") {
onSelectNode(item as INode);
}
});
graph.on('dbclick', (ev: GraphEvent) => {
console.log("dbclick", ev);
graph.on('dblclick', (ev: GraphEvent) => {
console.log("dblclick", ev);
const item = ev.item;
if (item && item.getType() == 'node') {
const commandManager: CommandManager = graph.get('commandManager');
if (commandManager.canExecute(graph, EditorCommand.Fold)) {
commandManager.execute(graph, EditorCommand.Fold);
} else {
commandManager.execute(graph, EditorCommand.Unfold);
}
}
});
graph.on('dragenter', (ev: GraphEvent) => {
@@ -61,8 +75,9 @@ class BehaviorTree extends React.Component<BehaviorTreeProps> {
}}
data={data}
ref={component => {
if (component) {
if (component && !this.graph) {
this.initGraph(component.graph);
this.mind = component;
}
}}
/>
-2
View File
@@ -17,7 +17,6 @@ class Panel extends React.Component<NodePanelProps> {
}
renderNode() {
console.log("NodePanel render", this.props);
const { curNode } = this.props;
return (
<div>
@@ -27,7 +26,6 @@ class Panel extends React.Component<NodePanelProps> {
}
render() {
console.log("NodePanel render", this.props);
const { curNode } = this.props;
return (
<Card title="节点信息" style={{ height: "100%" }}>