增加上一步高亮的Model与原来的Model一样的功能

This commit is contained in:
cjc 2022-04-29 22:42:03 +08:00
parent d01f552e61
commit 68982ebcb0
2 changed files with 33 additions and 3 deletions

View File

@ -23,6 +23,7 @@ export class Reconcile {
private engine: Engine;
private renderer: Renderer;
private isFirstPatch: boolean;
private prevUpdate: string[][] = [];
constructor(engine: Engine, renderer: Renderer) {
this.engine = engine;
@ -167,6 +168,14 @@ export class Reconcile {
return removedModels;
}
private getModelsById(ids: string[], modelList: SVModel[]): SVModel[] {
return modelList.filter(item =>
ids?.find(id => {
return id === item.id;
})
);
}
/**
*
* @param prevModelList
@ -231,6 +240,10 @@ export class Reconcile {
return freedNodes;
}
public setPrevUpdataId(prevUpdataId: string[]) {
this.prevUpdate.push(prevUpdataId);
}
// ------------------------------------------------------------------------------------------------
/**
@ -392,18 +405,29 @@ export class Reconcile {
prevModelList: SVModel[],
modelList: SVModel[],
accumulateLeakModels: SVModel[],
isDiffLeak: boolean
isDiffLeak: boolean,
hasTriggerLastStep: boolean
): DiffResult {
if (hasTriggerLastStep) {
this.prevUpdate.pop();
}
const continuousModels: SVModel[] = this.getContinuousModels(prevModelList, modelList);
const leakModels: SVModel[] = isDiffLeak ? [] : this.getLeakModels(layoutGroupTable, prevModelList, modelList);
const appendModels: SVModel[] = this.getAppendModels(prevModelList, modelList, accumulateLeakModels);
const removeModels: SVModel[] = this.getRemoveModels(prevModelList, modelList, accumulateLeakModels);
const updateModels: SVModel[] = [
const updateModels: SVModel[] = hasTriggerLastStep ? [...this.getModelsById(this.prevUpdate.pop(), modelList)]: [
...this.getReTargetMarkers(prevModelList, modelList),
...this.getLabelChangeModels(prevModelList, modelList),
...this.filterUnChangeModelsOfAppend(appendModels, prevModelList),
...leakModels,
];
let UpdataModelsId: string [] =[];
for (let model of updateModels) {
UpdataModelsId.push(model.id);
}
this.prevUpdate?.push(UpdataModelsId);
const freedModels: SVNode[] = this.getFreedModels(prevModelList, modelList);
return {

View File

@ -168,6 +168,10 @@ export class ViewContainer {
});
}
private setPrevUpdateId(prevUpdataId: string[]) {
this.reconcile.setPrevUpdataId(prevUpdataId)
}
/**
*
* @param models
@ -184,6 +188,7 @@ export class ViewContainer {
// 如果数据没变的话,直接退出
if (isSameSources) {
this.setPrevUpdateId([])
return;
}
@ -196,7 +201,8 @@ export class ViewContainer {
modelList,
this.accumulateLeakModels,
// handleUpdate?.isEnterFunction
isDiffLeak
isDiffLeak,
handleUpdate?.hasTriggerLastStep
),
renderModelList = [...modelList, ...diffResult.REMOVE, ...diffResult.LEAKED, ...this.accumulateLeakModels];