diff --git a/src/View/reconcile.ts b/src/View/reconcile.ts index 6c00cc1..cfb05b9 100644 --- a/src/View/reconcile.ts +++ b/src/View/reconcile.ts @@ -6,6 +6,7 @@ import { SVLink } from '../Model/SVLink'; import { SVModel } from '../Model/SVModel'; import { SVNode } from '../Model/SVNode'; import { SVAddressLabel, SVMarker, SVNodeAppendage } from '../Model/SVNodeAppendage'; +import { handleUpdate } from '../sources'; import { Animations } from './animation'; import { Renderer } from './renderer'; @@ -272,7 +273,7 @@ export class Reconcile { Animations.APPEND(item.G6Item, { duration, timingFunction, - callback: () => item.afterRender() + callback: () => item.afterRender(), }); } }); @@ -422,13 +423,13 @@ export class Reconcile { * @param diffResult * @param isFirstRender */ - public patch(diffResult: DiffResult,handleUpdata: any) { + public patch(diffResult: DiffResult, handleUpdate: handleUpdate) { const { APPEND, REMOVE, FREED, LEAKED, UPDATE, CONTINUOUS, ACCUMULATE_LEAK } = diffResult; this.handleAccumulateLeakModels(ACCUMULATE_LEAK); - // 第一次渲染和进入函数的时候不高亮变化的元素 - if (this.isFirstPatch === false && !handleUpdata.isEnterFunction && !handleUpdata.isFirstDebug) { + // 第一次渲染和进入函数的时候不高亮变化的元素 + if (this.isFirstPatch === false && !handleUpdate?.isEnterFunction && !handleUpdate?.isFirstDebug) { this.handleChangeModels(UPDATE); } diff --git a/src/View/viewContainer.ts b/src/View/viewContainer.ts index ecc2b64..ec8a52d 100644 --- a/src/View/viewContainer.ts +++ b/src/View/viewContainer.ts @@ -16,6 +16,7 @@ import { SolveNodeAppendagesDrag, SolveZoomCanvasWithLeak, } from '../BehaviorHelper/behaviorIssueHelper'; +import { handleUpdate } from '../sources'; export class ViewContainer { private engine: Engine; @@ -140,13 +141,18 @@ export class ViewContainer { * @param models * @param layoutFn */ - render(layoutGroupTable: LayoutGroupTable, isSameSources: boolean, handleUpdata: any) { + render(layoutGroupTable: LayoutGroupTable, isSameSources: boolean, handleUpdate: handleUpdate) { const modelList = Util.convertGroupTable2ModelList(layoutGroupTable); - // 如果数据没变的话 + // 如果数据没变的话 if (isSameSources) { - modelList.forEach(item => item.restoreHighlight()); - return; + modelList.forEach(item => { + // 不是free节点才进行还原 + if(!item.freed) { + item.restoreHighlight() + } + }); + return; } const diffResult = this.reconcile.diff( @@ -154,7 +160,7 @@ export class ViewContainer { this.prevModelList, modelList, this.accumulateLeakModels, - handleUpdata.isEnterFunction + handleUpdate?.isEnterFunction ), renderModelList = [...modelList, ...diffResult.REMOVE, ...diffResult.LEAKED, ...diffResult.ACCUMULATE_LEAK]; @@ -182,7 +188,7 @@ export class ViewContainer { this.beforeRender(); this.renderer.render(renderModelList); // 渲染视图 - this.reconcile.patch(diffResult,handleUpdata); // 对视图上的某些变化进行对应的动作,比如:节点创建动画,节点消失动画等 + this.reconcile.patch(diffResult, handleUpdate); // 对视图上的某些变化进行对应的动作,比如:节点创建动画,节点消失动画等 this.afterRender(); this.layoutGroupTable = layoutGroupTable; diff --git a/src/engine.ts b/src/engine.ts index 1fb048e..c004815 100644 --- a/src/engine.ts +++ b/src/engine.ts @@ -1,4 +1,4 @@ -import { Sources } from "./sources"; +import { handleUpdate, Sources } from "./sources"; import { LayoutGroupTable, ModelConstructor } from "./Model/modelConstructor"; import { AnimationOptions, BehaviorOptions, EngineOptions, LayoutGroupOptions, ViewOptions } from "./options"; import { EventBus } from "./Common/eventBus"; @@ -59,7 +59,7 @@ export class Engine { return; } - let handleUpdate = source.handleUpdate, + let handleUpdate: handleUpdate = source.handleUpdate, stringSource = JSON.stringify(source); if (this.prevStringSource === stringSource) { diff --git a/src/sources.ts b/src/sources.ts index 6e0d5b5..5f08fbd 100644 --- a/src/sources.ts +++ b/src/sources.ts @@ -1,4 +1,3 @@ - // 连接目标信息 export type LinkTarget = number | string; @@ -10,24 +9,19 @@ export type sourceMarkerData = string | string[]; // 源数据单元 export interface SourceNode { - id: string | number; - [key: string]: any | sourceLinkData | sourceMarkerData; + id: string | number; + [key: string]: any | sourceLinkData | sourceMarkerData; } -export interface handleUpdata { - isEnterFunction: boolean, - isFirstDebug: boolean +export interface handleUpdate { + isEnterFunction: boolean; + isFirstDebug: boolean; } - export type Sources = { - - [key: string]: { - data: SourceNode[]; - layouter: string; - }; - handleUpdata?:any + [key: string]: { + data: SourceNode[]; + layouter: string; + }; + handleUpdate?: handleUpdate | any; }; - - -