diff --git a/demo/data.js b/demo/data.js index 17c4d38..4909b35 100644 --- a/demo/data.js +++ b/demo/data.js @@ -1,45 +1,106 @@ const SOURCES_DATA = [{ - "HashTable": { + "LinkList0": { "data": [{ "id": "0x616eb0", - "index": 0, - "external": "H", - "data": "", - "disable": true, - "empty": true - }, - { - "id": "0x616ec0", - "index": 1, - "data": "UV", - "disable": true, - }, - { - "id": "0x616ed0", - "index": 2, - "data": "FI" - }, - { - "id": "0x616ee0", - "index": 3, - "data": "", - "disable": true, - "empty": true + "data": "Z", + "next": "0x616ef0", + "loopNext": null, + "rootExternal": [ + "L" + ], + "type": "default" }, { + "freed": true, "id": "0x616ef0", - "index": 4, - "data": "SO" + "data": "", + "next": "0x605010", + "loopNext": null, + "type": "default" }, { - "id": "0x616f00", - "index": 5, - "data": "", - "disable": true, - "empty": true + "id": "0x605010", + "data": "1", + "external": [ + "t" + ], + "next": null, + "loopNext": null, + "type": "default" } ], - "layouter": "HashTable" + "layouter": "LinkList" }, - "isEnterFunction": false + "handleUpdate": { + "isEnterFunction": false, + "isFirstDebug": false + } +}, { + "LinkList0": { + "data": [{ + "id": "0x616eb0", + "data": "Z", + "external": [ + "L" + ], + "next": "0x616ef0", + "loopNext": null + }, + { + "freed": true, + "id": "0x616ef0", + "data": "", + "next": "0x605010", + "loopNext": null + }, + { + "id": "0x605010", + "data": "1", + "external": [ + "t" + ], + "next": null, + "loopNext": null + } + ], + "layouter": "LinkList" + }, + "handleUpdate": { + "isEnterFunction": false, + "isFirstDebug": false + } +}, { + "LinkList0": { + "data": [{ + "id": "0x616eb0", + "data": "Z", + "external": [ + "L" + ], + "next": "0x616ef0", + "loopNext": null + }, + { + "freed": true, + "id": "0x616ef0", + "data": "", + "next": "0x605010", + "loopNext": null + }, + { + "id": "0x605010", + "data": "1", + "external": [ + "t" + ], + "next": null, + "loopNext": null + } + ], + "layouter": "LinkList" + }, + "handleUpdate": { + "isEnterFunction": false, + "isFirstDebug": false + } }]; \ No newline at end of file diff --git a/src/View/reconcile.ts b/src/View/reconcile.ts index 8b2e0c6..6c00cc1 100644 --- a/src/View/reconcile.ts +++ b/src/View/reconcile.ts @@ -422,13 +422,13 @@ export class Reconcile { * @param diffResult * @param isFirstRender */ - public patch(diffResult: DiffResult,isEnterFunction: boolean) { + public patch(diffResult: DiffResult,handleUpdata: any) { const { APPEND, REMOVE, FREED, LEAKED, UPDATE, CONTINUOUS, ACCUMULATE_LEAK } = diffResult; this.handleAccumulateLeakModels(ACCUMULATE_LEAK); - // 第一次渲染的时候不高亮变化的元素 - if (this.isFirstPatch === false && !isEnterFunction) { + // 第一次渲染和进入函数的时候不高亮变化的元素 + if (this.isFirstPatch === false && !handleUpdata.isEnterFunction && !handleUpdata.isFirstDebug) { this.handleChangeModels(UPDATE); } diff --git a/src/View/viewContainer.ts b/src/View/viewContainer.ts index 250b9ed..ecc2b64 100644 --- a/src/View/viewContainer.ts +++ b/src/View/viewContainer.ts @@ -140,7 +140,7 @@ export class ViewContainer { * @param models * @param layoutFn */ - render(layoutGroupTable: LayoutGroupTable, isSameSources: boolean, isEnterFunction: boolean) { + render(layoutGroupTable: LayoutGroupTable, isSameSources: boolean, handleUpdata: any) { const modelList = Util.convertGroupTable2ModelList(layoutGroupTable); // 如果数据没变的话 @@ -154,7 +154,7 @@ export class ViewContainer { this.prevModelList, modelList, this.accumulateLeakModels, - isEnterFunction + handleUpdata.isEnterFunction ), renderModelList = [...modelList, ...diffResult.REMOVE, ...diffResult.LEAKED, ...diffResult.ACCUMULATE_LEAK]; @@ -182,7 +182,7 @@ export class ViewContainer { this.beforeRender(); this.renderer.render(renderModelList); // 渲染视图 - this.reconcile.patch(diffResult,isEnterFunction); // 对视图上的某些变化进行对应的动作,比如:节点创建动画,节点消失动画等 + this.reconcile.patch(diffResult,handleUpdata); // 对视图上的某些变化进行对应的动作,比如:节点创建动画,节点消失动画等 this.afterRender(); this.layoutGroupTable = layoutGroupTable; diff --git a/src/engine.ts b/src/engine.ts index 1e7b3cb..1fb048e 100644 --- a/src/engine.ts +++ b/src/engine.ts @@ -59,7 +59,7 @@ export class Engine { return; } - let isEnterFunction = source.isEnterFunction, + let handleUpdate = source.handleUpdate, stringSource = JSON.stringify(source); if (this.prevStringSource === stringSource) { @@ -79,7 +79,7 @@ export class Engine { } // 2 渲染(使用g6进行渲染) - this.viewContainer.render(layoutGroupTable, isSameSources, isEnterFunction); + this.viewContainer.render(layoutGroupTable, isSameSources, handleUpdate); } diff --git a/src/sources.ts b/src/sources.ts index 4703de2..6e0d5b5 100644 --- a/src/sources.ts +++ b/src/sources.ts @@ -14,14 +14,19 @@ export interface SourceNode { [key: string]: any | sourceLinkData | sourceMarkerData; } +export interface handleUpdata { + isEnterFunction: boolean, + isFirstDebug: boolean +} + export type Sources = { - enterFunction: any; + [key: string]: { data: SourceNode[]; layouter: string; }; - isEnterFunction?: any; + handleUpdata?:any };