add animate
This commit is contained in:
1 parent
25083f9b9d
commit
167750bb99
2 files changed
+15
-3
No files matched your search
@@ -42,7 +42,7 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
|
|||||||
container: this.ref.current,
|
container: this.ref.current,
|
||||||
width: window.screen.width * 0.66,
|
width: window.screen.width * 0.66,
|
||||||
height: window.screen.height,
|
height: window.screen.height,
|
||||||
animate: false,
|
animate: true,
|
||||||
// fitCenter: true,
|
// fitCenter: true,
|
||||||
modes: {
|
modes: {
|
||||||
default: [
|
default: [
|
||||||
@@ -56,6 +56,7 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
|
|||||||
onChange: (item, collapsed) => {
|
onChange: (item, collapsed) => {
|
||||||
const data = item.getModel();
|
const data = item.getModel();
|
||||||
data.collapsed = collapsed;
|
data.collapsed = collapsed;
|
||||||
|
this.onSelectNode(item.getID());
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -112,6 +113,14 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
graph.on('node:click', (e: G6GraphEvent) => {
|
||||||
|
if (e.target.get('name') === 'collapse-icon') {
|
||||||
|
e.item.getModel().collapsed = !e.item.getModel().collapsed;
|
||||||
|
graph.setItemState(e.item, 'collapsed', e.item.getModel().collapsed as boolean);
|
||||||
|
graph.layout();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const clearDragDstState = () => {
|
const clearDragDstState = () => {
|
||||||
if (this.dragDstId) {
|
if (this.dragDstId) {
|
||||||
graph.setItemState(this.dragDstId, 'dragRight', false);
|
graph.setItemState(this.dragDstId, 'dragRight', false);
|
||||||
@@ -237,8 +246,10 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// console.log("cur data", graph.findDataById('1'));
|
// console.log("cur data", graph.findDataById('1'));
|
||||||
|
graph.set('animate', false);
|
||||||
graph.changeData();
|
graph.changeData();
|
||||||
graph.layout();
|
graph.layout();
|
||||||
|
graph.set('animate', true);
|
||||||
});
|
});
|
||||||
|
|
||||||
const str = fs.readFileSync(this.props.filepath, 'utf8');
|
const str = fs.readFileSync(this.props.filepath, 'utf8');
|
||||||
@@ -255,6 +266,7 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
|
|||||||
const graph = this.graph;
|
const graph = this.graph;
|
||||||
|
|
||||||
if (this.state.curNodeId) {
|
if (this.state.curNodeId) {
|
||||||
|
console.log("unselect", this.state.curNodeId);
|
||||||
graph.setItemState(this.state.curNodeId, 'selected', false);
|
graph.setItemState(this.state.curNodeId, 'selected', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ export default class Main extends Component {
|
|||||||
'drag-down': {
|
'drag-down': {
|
||||||
fillOpacity: 0.6,
|
fillOpacity: 0.6,
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
draw(cfg, group) {
|
draw(cfg, group) {
|
||||||
@@ -298,7 +298,7 @@ export default class Main extends Component {
|
|||||||
// visible: false,
|
// visible: false,
|
||||||
});
|
});
|
||||||
return shape;
|
return shape;
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'single-node',
|
'single-node',
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user