change collapse-icon
This commit is contained in:
1 parent
fd3b750007
commit
7d8d077440
2 files changed
+12
-11
No files matched your search
@@ -54,9 +54,13 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
|
|||||||
type: 'collapse-expand',
|
type: 'collapse-expand',
|
||||||
trigger: 'dblclick',
|
trigger: 'dblclick',
|
||||||
onChange: (item, collapsed) => {
|
onChange: (item, collapsed) => {
|
||||||
|
this.onSelectNode(item.getID());
|
||||||
const data = item.getModel();
|
const data = item.getModel();
|
||||||
data.collapsed = collapsed;
|
data.collapsed = collapsed;
|
||||||
this.onSelectNode(item.getID());
|
graph.setItemState(item, 'collapsed', data.collapsed as boolean);
|
||||||
|
const icon = data.collapsed ? G6.Marker.expand : G6.Marker.collapse;
|
||||||
|
const marker = item.get('group').find((ele: any) => ele.get('name') === 'collapse-icon');
|
||||||
|
marker.attr('symbol', icon);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -113,14 +117,6 @@ 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);
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ const NODE_COLORS: any = {
|
|||||||
|
|
||||||
|
|
||||||
export default function (settings: Settings) {
|
export default function (settings: Settings) {
|
||||||
|
const collapseStyle: any = {
|
||||||
|
'collapse-icon': {
|
||||||
|
// symbol: G6.Marker.expand,
|
||||||
|
fill: 'blue',
|
||||||
|
}
|
||||||
|
};
|
||||||
G6.registerNode(
|
G6.registerNode(
|
||||||
'TreeNode',
|
'TreeNode',
|
||||||
{
|
{
|
||||||
@@ -206,13 +212,12 @@ export default function (settings: Settings) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfg.children) {
|
if (Array.isArray(cfg.children) && cfg.children.length > 0) {
|
||||||
group.addShape('marker', {
|
group.addShape('marker', {
|
||||||
attrs: {
|
attrs: {
|
||||||
x: w / 2,
|
x: w / 2,
|
||||||
y: 0,
|
y: 0,
|
||||||
r: 6,
|
r: 6,
|
||||||
cursor: 'pointer',
|
|
||||||
symbol: G6.Marker.collapse,
|
symbol: G6.Marker.collapse,
|
||||||
stroke: '#666',
|
stroke: '#666',
|
||||||
lineWidth: 1,
|
lineWidth: 1,
|
||||||
|
|||||||
Reference in new issue
Block a user