From f9bf3575a6554f0afc1cd67f246bc0ebbd3a9a4a Mon Sep 17 00:00:00 2001 From: cjc <431909623@qq.com> Date: Mon, 9 May 2022 14:47:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8A=E4=B8=80=E6=AD=A5?= =?UTF-8?q?=E6=B3=84=E6=BC=8F=E5=8C=BA=E4=B8=8D=E8=83=BD=E5=8F=98=E7=BA=A2?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/View/reconcile.ts | 12 +++++++++--- src/View/viewContainer.ts | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/View/reconcile.ts b/src/View/reconcile.ts index b1ddf46..4f84b0f 100644 --- a/src/View/reconcile.ts +++ b/src/View/reconcile.ts @@ -168,12 +168,18 @@ export class Reconcile { return removedModels; } - private getModelsById(ids: string[], modelList: SVModel[]): SVModel[] { - return modelList.filter(item => + // 在视图上所有model中根据id查找model + private getModelsById(ids: string[], modelList: SVModel[], accumulateLeakModels: SVModel[]): SVModel[] { + const updateModels = modelList.filter(item => ids?.find(id => { return id === item.id; }) ); + const updateLeakModels = accumulateLeakModels.filter(item => + ids?.find(id => { + return id === item.id; + })); + return [ ...updateModels,...updateLeakModels]; } /** @@ -416,7 +422,7 @@ export class Reconcile { const appendModels: SVModel[] = this.getAppendModels(prevModelList, modelList, accumulateLeakModels); const removeModels: SVModel[] = this.getRemoveModels(prevModelList, modelList, accumulateLeakModels); const updateModels: SVModel[] = hasTriggerLastStep - ? [...this.getModelsById(this.prevUpdate.pop(), modelList)] + ? [...this.getModelsById(this.prevUpdate.pop(), modelList,accumulateLeakModels)] : [ ...this.getReTargetMarkers(prevModelList, modelList), ...this.getLabelChangeModels(prevModelList, modelList), diff --git a/src/View/viewContainer.ts b/src/View/viewContainer.ts index 5d405a0..540b30e 100644 --- a/src/View/viewContainer.ts +++ b/src/View/viewContainer.ts @@ -226,6 +226,7 @@ export class ViewContainer { const layoutMode = this.engine.viewOptions.layoutMode; this.accumulateLeakModels.push(...diffResult.LEAKED); // 对泄漏节点进行向后累积 + this.renderer.build(renderModelList); // 首先在离屏canvas渲染先 this.layoutProvider.layoutAll(layoutGroupTable, this.accumulateLeakModels, layoutMode); // 进行布局(设置model的x,y,样式等)