fix: 修复泄漏区布局问题

This commit is contained in:
黎智洲 2022-02-25 18:35:16 +08:00
commit 97749ec35e
6 changed files with 144 additions and 176 deletions

View File

@ -95,145 +95,143 @@
});
let data = [{
"BinaryTree0": {
"data": [{
"external": [
"T1"
],
"child": [
"0x617ee0",
"0x617f10"
],
"id": "0x617eb0",
"name": "T1",
"data": "Z",
"root": true,
"type": "default"
}, {
"child": [
"0x0",
"0x0"
],
"id": "0x617ee0",
"name": "T1->lchild",
"data": "A",
"type": "default"
}, {
"child": [
"0x0",
"0x0"
],
"id": "0x617f10",
"name": "T1->rchild",
"data": "B",
"type": "default",
"external": [
"r",
"t"
]
}],
"layouter": "BinaryTree"
},
"BinaryTree3": {
"data": [{
"external": [
"T2",
"r2"
],
"child": [
"0x617f70",
"0x0"
],
"id": "0x617f40",
"name": "T2",
"data": "Z",
"root": true,
"type": "default"
}, {
"child": [
"0x0",
"0x0"
],
"id": "0x617f70",
"name": "T2->lchild",
"data": "D",
"type": "default",
"external": [
"t2"
]
}],
"layouter": "BinaryTree"
}
}, {
"BinaryTree0": {
"data": [{
"external": [
"T1"
],
"child": [
"0x617ee0",
"0x617f10"
],
"id": "0x617eb0",
"name": "T1",
"data": "Z",
"root": true,
"type": "default"
}, {
"child": [
"0x0",
"0x0"
],
"id": "0x617ee0",
"name": "T1->lchild",
"data": "A",
"type": "default"
}, {
"child": [
"0x0",
"0x617eb0"
],
"id": "0x617f10",
"name": "T1->rchild",
"data": "B",
"type": "default"
}],
"layouter": "BinaryTree"
},
"BinaryTree3": {
"data": [{
"external": [
"T2",
"r2"
],
"child": [
"0x617f70",
"0x0"
],
"id": "0x617f40",
"name": "T2",
"data": "Z",
"root": true,
"type": "default"
}, {
"child": [
"0x0",
"0x0"
],
"id": "0x617f70",
"name": "T2->lchild",
"data": "D",
"type": "default",
"external": [
"t2"
]
}],
"layouter": "BinaryTree"
}
}
];
"BinaryTree0": {
"data": [{
"external": [
"T"
],
"child": [
"0x616060",
"0x615f40"
],
"id": "0x615f10",
"name": "T",
"data": "F",
"root": true,
"type": "default"
}, {
"child": [
"0x0",
"0x616090"
],
"id": "0x616060",
"name": "T->lchild",
"data": "A",
"type": "default"
}, {
"child": [
"0x6160c0",
"0x0"
],
"id": "0x616090",
"name": "(T->lchild)->rchild",
"data": "E",
"type": "default"
}, {
"child": [
"0x0",
"0x0"
],
"id": "0x6160c0",
"name": "((T->lchild)->rchild)->lchild",
"data": "D",
"type": "default"
}, {
"child": [
"0x615f70",
"0x615fd0"
],
"id": "0x615f40",
"name": "T->rchild",
"data": "U",
"type": "default"
}, {
"child": [
"0x615fa0",
"0x616000"
],
"id": "0x615f70",
"name": "(T->rchild)->lchild",
"data": "S",
"type": "default"
}, {
"child": [
"0x0",
"0x0"
],
"id": "0x615fa0",
"name": "((T->rchild)->lchild)->lchild",
"data": "R",
"type": "default"
}, {
"child": [
"0x0",
"0x0"
],
"id": "0x616000",
"name": "((T->rchild)->lchild)->rchild",
"data": "T",
"type": "default"
}, {
"child": [
"0x0",
"0x616030"
],
"id": "0x615fd0",
"name": "(T->rchild)->rchild",
"data": "V",
"type": "default"
}, {
"child": [
"0x0",
"0x0"
],
"id": "0x616030",
"name": "((T->rchild)->rchild)->rchild",
"data": "X",
"type": "default"
}],
"layouter": "BinaryTree"
},
"isEnterFunction": true
}, {
"BinaryTree0": {
"data": [{
"external": [
"T"
],
"child": [
"0x0",
"0x616090"
],
"id": "0x616060",
"name": "T",
"data": "A",
"root": true,
"type": "default"
}, {
"child": [
"0x6160c0",
"0x0"
],
"id": "0x616090",
"name": "T->rchild",
"data": "E",
"type": "default"
}, {
"child": [
"0x0",
"0x0"
],
"id": "0x6160c0",
"name": "(T->rchild)->lchild",
"data": "D",
"type": "default"
}],
"layouter": "BinaryTree"
},
"isEnterFunction": true
}];
let dataIndex = 0,
curData = data[dataIndex];

31
dist/sv.js vendored

File diff suppressed because one or more lines are too long

View File

@ -367,9 +367,9 @@ export class Reconcile {
* @param accumulateLeakModels
* @returns
*/
public diff(layoutGroupTable: LayoutGroupTable, prevModelList: SVModel[], modelList: SVModel[], accumulateLeakModels: SVModel[]): DiffResult {
public diff(layoutGroupTable: LayoutGroupTable, prevModelList: SVModel[], modelList: SVModel[], accumulateLeakModels: SVModel[], isEnterFunction: boolean): DiffResult {
const continuousModels: SVModel[] = this.getContinuousModels(prevModelList, modelList);
const leakModels: SVModel[] = this.getLeakModels(layoutGroupTable, prevModelList, modelList);
const leakModels: SVModel[] = isEnterFunction? []: this.getLeakModels(layoutGroupTable, prevModelList, modelList);
const appendModels: SVModel[] = this.getAppendModels(prevModelList, modelList, accumulateLeakModels);
const removeModels: SVModel[] = this.getRemoveModels(prevModelList, modelList);
const updateModels: SVModel[] = [

View File

@ -140,9 +140,9 @@ export class ViewContainer {
* @param models
* @param layoutFn
*/
render(layoutGroupTable: LayoutGroupTable, a: boolean) {
render(layoutGroupTable: LayoutGroupTable, isEnterFunction: boolean) {
const modelList = Util.convertGroupTable2ModelList(layoutGroupTable),
diffResult = this.reconcile.diff(this.layoutGroupTable, this.prevModelList, modelList, this.accumulateLeakModels),
diffResult = this.reconcile.diff(this.layoutGroupTable, this.prevModelList, modelList, this.accumulateLeakModels, isEnterFunction),
renderModelList = [
...modelList,
...diffResult.REMOVE,

View File

@ -67,7 +67,7 @@ export class Engine {
const layoutGroupTable = this.modelConstructor.construct(source);
// 2 渲染使用g6进行渲染
this.viewContainer.render(layoutGroupTable, source.enterFunction as boolean);
this.viewContainer.render(layoutGroupTable, source.isEnterFunction as boolean);
}

View File

@ -20,7 +20,8 @@ export type Sources = {
[key: string]: {
data: SourceNode[];
layouter: string;
}
};
isEnterFunction?: any;
};