fix: 大量bug修复
This commit is contained in:
@@ -265,6 +265,7 @@ export class LayoutProvider {
|
||||
* @param layoutGroupTable
|
||||
* @param leakModels
|
||||
* @param hasLeak
|
||||
* @param needFitCenter
|
||||
*/
|
||||
public layoutAll(layoutGroupTable: LayoutGroupTable, accumulateLeakModels: SVModel[], leakModels: SVModel[]) {
|
||||
this.preLayoutProcess(layoutGroupTable);
|
||||
|
||||
+14
-1
@@ -25,11 +25,13 @@ export class Reconcile {
|
||||
|
||||
private engine: Engine;
|
||||
private renderer: Renderer;
|
||||
private prevChangeModels: SVModel[];
|
||||
private isFirstPatch: boolean;
|
||||
|
||||
constructor(engine: Engine, renderer: Renderer) {
|
||||
this.engine = engine;
|
||||
this.renderer = renderer;
|
||||
this.prevChangeModels = [];
|
||||
this.isFirstPatch = true;
|
||||
}
|
||||
|
||||
@@ -316,6 +318,10 @@ export class Reconcile {
|
||||
* @param models
|
||||
*/
|
||||
private handleChangeModels(models: SVModel[]) {
|
||||
if(models.length === 0) {
|
||||
models = this.prevChangeModels;
|
||||
}
|
||||
|
||||
const changeHighlightColor: string = this.engine.viewOptions.updateHighlight;
|
||||
|
||||
if (!changeHighlightColor || typeof changeHighlightColor !== 'string') {
|
||||
@@ -338,6 +344,8 @@ export class Reconcile {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.prevChangeModels = models;
|
||||
}
|
||||
|
||||
|
||||
@@ -389,6 +397,8 @@ export class Reconcile {
|
||||
ACCUMULATE_LEAK
|
||||
} = diffResult;
|
||||
|
||||
this.handleAccumulateLeakModels(ACCUMULATE_LEAK);
|
||||
|
||||
// 第一次渲染的时候不高亮变化的元素
|
||||
if (this.isFirstPatch === false) {
|
||||
this.handleChangeModels(UPDATE);
|
||||
@@ -399,10 +409,13 @@ export class Reconcile {
|
||||
this.handleAppendModels(APPEND);
|
||||
this.handleLeakModels(LEAKED);
|
||||
this.handleRemoveModels(REMOVE);
|
||||
this.handleAccumulateLeakModels(ACCUMULATE_LEAK);
|
||||
|
||||
if(this.isFirstPatch) {
|
||||
this.isFirstPatch = false;
|
||||
}
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
this.prevChangeModels.length = 0;
|
||||
}
|
||||
}
|
||||
@@ -115,6 +115,9 @@ export class Renderer {
|
||||
item.G6Item = this.g6Instance.findById(item.id);
|
||||
item.G6Item['SVModel'] = item;
|
||||
});
|
||||
|
||||
this.g6Instance.getEdges().forEach(item => item.toFront());
|
||||
this.g6Instance.paint();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+21
-13
@@ -61,8 +61,19 @@ export class ViewContainer {
|
||||
* 对主视图进行重新布局
|
||||
*/
|
||||
reLayout() {
|
||||
this.layoutProvider.layoutAll(this.prevLayoutGroupTable, [], this.accumulateLeakModels);
|
||||
this.getG6Instance().refresh();
|
||||
const g6Instance = this.getG6Instance(),
|
||||
group = g6Instance.getGroup(),
|
||||
matrix = group.getMatrix();
|
||||
|
||||
if (matrix) {
|
||||
let dx = matrix[6],
|
||||
dy = matrix[7];
|
||||
|
||||
g6Instance.translate(-dx, -dy);
|
||||
}
|
||||
|
||||
this.layoutProvider.layoutAll(this.prevLayoutGroupTable, this.accumulateLeakModels, []);
|
||||
g6Instance.refresh();
|
||||
}
|
||||
|
||||
|
||||
@@ -156,6 +167,11 @@ export class ViewContainer {
|
||||
*/
|
||||
destroy() {
|
||||
this.renderer.destroy();
|
||||
this.reconcile.destroy();
|
||||
this.layoutProvider = null;
|
||||
this.prevLayoutGroupTable = null;
|
||||
this.prevModelList.length = 0;
|
||||
this.accumulateLeakModels.length = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,15 +179,9 @@ export class ViewContainer {
|
||||
|
||||
|
||||
/**
|
||||
* 把渲染前要触发的逻辑放在这里
|
||||
* 把渲染后要触发的逻辑放在这里
|
||||
*/
|
||||
private afterRender() {
|
||||
const g6Instance = this.renderer.getG6Instance();
|
||||
|
||||
// 把所有连线置顶
|
||||
g6Instance.getEdges().forEach(item => item.toFront());
|
||||
g6Instance.paint();
|
||||
|
||||
this.prevModelList.forEach(item => {
|
||||
if (item.leaked === false) {
|
||||
item.discarded = true;
|
||||
@@ -180,11 +190,9 @@ export class ViewContainer {
|
||||
}
|
||||
|
||||
/**
|
||||
* 把渲染后要触发的逻辑放在这里
|
||||
* 把渲染前要触发的逻辑放在这里
|
||||
*/
|
||||
private beforeRender() {
|
||||
|
||||
}
|
||||
private beforeRender() { }
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user