fix: 修复多个free节点显示的bug
This commit is contained in:
parent
324a085867
commit
80e761a57e
@ -58,7 +58,7 @@ SV.registerLayouter('LinkList', {
|
||||
},
|
||||
marker: {
|
||||
rootExternal: {
|
||||
type: 'cursor',
|
||||
type: 'pointer',
|
||||
anchor: 6,
|
||||
offset: 8,
|
||||
style: {
|
||||
@ -66,7 +66,7 @@ SV.registerLayouter('LinkList', {
|
||||
}
|
||||
},
|
||||
external: {
|
||||
type: 'cursor',
|
||||
type: 'pointer',
|
||||
anchor: 0,
|
||||
offset: 8,
|
||||
style: {
|
||||
|
@ -20,7 +20,7 @@
|
||||
element: {
|
||||
default: {
|
||||
type: 'link-list-node',
|
||||
label: '[data]',
|
||||
label: '[id]',
|
||||
size: [60, 30],
|
||||
style: {
|
||||
stroke: '#333',
|
||||
|
@ -88,22 +88,31 @@
|
||||
|
||||
|
||||
let data = [{
|
||||
"LinkStack0": {
|
||||
"LinkStack1": {
|
||||
"data": [
|
||||
{ id: 6, next: 7 },
|
||||
{ id: 7, next: 8, freed: true },
|
||||
{ id: 8, external: 'h', data: '66' }
|
||||
{
|
||||
"id": 0,
|
||||
external: 'gg'
|
||||
}
|
||||
],
|
||||
"layouter": "LinkList"
|
||||
"layouter": "LinkStack"
|
||||
}
|
||||
}, {
|
||||
"LinkStack0": {
|
||||
"LinkStack1": {
|
||||
"data": [
|
||||
{ id: 6, next: 7 },
|
||||
{ id: 7, next: 8, freed: true },
|
||||
{ id: 8, freed: true, external: 'h' }
|
||||
{
|
||||
"id": 0
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"freed": true,
|
||||
},
|
||||
{
|
||||
"freed": true,
|
||||
"id": 2
|
||||
}
|
||||
],
|
||||
"layouter": "LinkList"
|
||||
"layouter": "LinkStack"
|
||||
}
|
||||
}];
|
||||
|
||||
|
2
dist/sv.js
vendored
2
dist/sv.js
vendored
File diff suppressed because one or more lines are too long
@ -20,7 +20,7 @@ export default G6.registerNode('pointer', {
|
||||
x: 0,
|
||||
y: 0,
|
||||
text: cfg.label,
|
||||
fill: style.fill || '#fafafa',
|
||||
fill: null,
|
||||
radius: 2
|
||||
},
|
||||
name: 'bgRect'
|
||||
|
@ -89,41 +89,31 @@ export class ViewManager {
|
||||
private getFreedModelList(prevLayoutGroupTable: LayoutGroupTable, layoutGroupTable: LayoutGroupTable): Model[] {
|
||||
let freedElements: Element[] = [],
|
||||
freedMarkers: Marker[] = [],
|
||||
freedGroup: LayoutGroup = null,
|
||||
freedGroupName: string = null,
|
||||
removeModels: Model[] = [];
|
||||
removeModels: Model[] = [],
|
||||
freedGroupName: string;
|
||||
|
||||
layoutGroupTable.forEach((group, key) => {
|
||||
let targetElements: Element[] = group.element.filter(item => item.freed),
|
||||
newFreedNode = null;
|
||||
let targetElements: Element[] = group.element.filter(item => item.freed);
|
||||
|
||||
targetElements.forEach(fItem => {
|
||||
removeModels.push(
|
||||
...Util.removeFromList(group.element, item => item.id === fItem.id),
|
||||
...Util.removeFromList(group.link, item => item.element.id === fItem.id || item.target.id === fItem.id),
|
||||
...Util.removeFromList(group.marker, item => item.target.id === fItem.id),
|
||||
);
|
||||
});
|
||||
|
||||
removeModels.map(model => {
|
||||
Util.removeFromList(group.modelList, item => item.id === model.id);
|
||||
});
|
||||
|
||||
// 找出最新的freed节点(防止上一次的freed节点被遗留在该次渲染,此时会出现大于一个freed节点)
|
||||
targetElements.forEach(item => {
|
||||
if (this.prevFreedElements.find(prevEle => prevEle.id === item.id) === undefined) {
|
||||
newFreedNode = item;
|
||||
freedGroupName = key;
|
||||
freedElements.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
if (targetElements.length) {
|
||||
freedGroupName = key;
|
||||
freedElements = [newFreedNode];
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
freedGroup = layoutGroupTable.get(freedGroupName);
|
||||
|
||||
freedElements.forEach(fItem => {
|
||||
removeModels.push(
|
||||
...Util.removeFromList(freedGroup.element, item => item.id === fItem.id),
|
||||
...Util.removeFromList(freedGroup.link, item => item.element.id === fItem.id || item.target.id === fItem.id),
|
||||
...Util.removeFromList(freedGroup.marker, item => item.target.id === fItem.id),
|
||||
);
|
||||
});
|
||||
|
||||
removeModels.map(model => {
|
||||
Util.removeFromList(freedGroup.modelList, item => item.id === model.id);
|
||||
});
|
||||
|
||||
freedElements.map(item => {
|
||||
|
Loading…
Reference in New Issue
Block a user