vislite 1.2.1-alpha.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG +283 -279
  2. package/README.md +197 -175
  3. package/lib/Buffer/index.es.js +1 -1
  4. package/lib/Buffer/index.es.min.js +1 -1
  5. package/lib/Canvas/index.es.js +1 -1
  6. package/lib/Canvas/index.es.min.js +1 -1
  7. package/lib/Cardinal/index.es.js +1 -1
  8. package/lib/Cardinal/index.es.min.js +1 -1
  9. package/lib/Eoap/index.es.js +1 -1
  10. package/lib/Eoap/index.es.min.js +1 -1
  11. package/lib/Hermite/index.es.js +1 -1
  12. package/lib/Hermite/index.es.min.js +1 -1
  13. package/lib/Matrix4/index.es.js +1 -1
  14. package/lib/Matrix4/index.es.min.js +1 -1
  15. package/lib/Mercator/index.es.js +1 -1
  16. package/lib/Mercator/index.es.min.js +1 -1
  17. package/lib/RawCanvas/index.es.js +1 -1
  18. package/lib/RawCanvas/index.es.min.js +1 -1
  19. package/lib/SVG/index.es.js +1 -1
  20. package/lib/SVG/index.es.min.js +1 -1
  21. package/lib/Shader/index.es.js +1 -1
  22. package/lib/Shader/index.es.min.js +1 -1
  23. package/lib/Texture/index.es.js +1 -1
  24. package/lib/Texture/index.es.min.js +1 -1
  25. package/lib/TreeLayout/index.es.js +6 -1
  26. package/lib/TreeLayout/index.es.min.js +2 -2
  27. package/lib/animation/index.es.js +1 -1
  28. package/lib/animation/index.es.min.js +1 -1
  29. package/lib/assemble/index.es.js +1 -1
  30. package/lib/assemble/index.es.min.js +1 -1
  31. package/lib/getLoopColors/index.es.js +1 -1
  32. package/lib/getLoopColors/index.es.min.js +1 -1
  33. package/lib/getWebGLContext/index.es.js +1 -1
  34. package/lib/getWebGLContext/index.es.min.js +1 -1
  35. package/lib/index.umd.js +6 -1
  36. package/lib/index.umd.min.js +2 -2
  37. package/lib/initOption/index.es.js +1 -1
  38. package/lib/initOption/index.es.min.js +1 -1
  39. package/lib/mergeOption/index.es.js +1 -1
  40. package/lib/mergeOption/index.es.min.js +1 -1
  41. package/lib/move/index.es.js +1 -1
  42. package/lib/move/index.es.min.js +1 -1
  43. package/lib/rotate/index.es.js +1 -1
  44. package/lib/rotate/index.es.min.js +1 -1
  45. package/lib/ruler/index.es.js +1 -1
  46. package/lib/ruler/index.es.min.js +1 -1
  47. package/lib/scale/index.es.js +1 -1
  48. package/lib/scale/index.es.min.js +1 -1
  49. package/lib/throttle/index.es.js +1 -1
  50. package/lib/throttle/index.es.min.js +1 -1
  51. package/package/animation/index.ts +1 -1
  52. package/package/throttle/index.ts +1 -1
  53. package/package.json +4 -5
  54. package/src/common/canvas/default.ts +2 -2
  55. package/src/common/canvas/gradient.ts +1 -1
  56. package/src/common/canvas/painter.ts +2 -2
  57. package/src/common/svg/gradient.ts +1 -1
  58. package/src/common/tree/toInnerTree.ts +61 -59
  59. package/src/common/type.ts +1 -1
  60. package/src/layout/TreeLayout.ts +194 -188
  61. package/types/Tree.d.ts +74 -69
  62. package/types/TreeLayout.d.ts +59 -54
  63. package/types/animation.d.ts +1 -1
  64. package/types/throttle.d.ts +1 -1
  65. package/types/throttleOption.d.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * throttle of VISLite JavaScript Library v1.2.1-alpha.0
2
+ * throttle of VISLite JavaScript Library v1.2.1
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  function t(t,e){var n={time:200,keep:!1,opportunity:"end"};if(e)for(var p in e)n[p]=e[p];var r,i=!1,o=!1,a=!1;return function(){const e=this;if(r=arguments,i)o=!0,a=!0;else{"end"!=n.opportunity&&t.apply(e,r),i=!0;var p=setInterval((()=>{o?n.keep||t.apply(e,r):("begin"!=n.opportunity&&(a||"end"==n.opportunity)&&t.apply(e,r),i=!1,a=!1,clearInterval(p)),o=!1}),n.time)}}}export{t as default};
@@ -1,3 +1,3 @@
1
- import { animation } from "@oipage/core.js/src/animation/index"
1
+ import { animation } from "oipage/corejs/animation/index"
2
2
 
3
3
  export default animation
@@ -1,3 +1,3 @@
1
- import { throttle } from "@oipage/core.js/src/throttle/index"
1
+ import { throttle } from "oipage/corejs/throttle/index"
2
2
 
3
3
  export default throttle
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vislite",
3
- "version": "1.2.1-alpha.0",
3
+ "version": "1.2.1",
4
4
  "description": "灵活、快速、简单的数据可视化交互式跨端前端库",
5
5
  "main": "./lib/index.umd.min.js",
6
6
  "typings": "./types/index.d.ts",
@@ -8,9 +8,9 @@
8
8
  "jsdelivr": "./lib/index.umd.min.js",
9
9
  "sideEffects": false,
10
10
  "scripts": {
11
- "init": "npm install && devby --copy ./node_modules/pageby/dist/pageby.min.js ./docs/js/min/pageby.min.js",
11
+ "init": "npm install && oipage-cli --copy ./node_modules/pageby/dist/pageby.min.js ./docs/js/min/pageby.min.js",
12
12
  "dev": "webpack serve --config ./build/webpack.config.js",
13
- "build": "devby --delete ./lib && node ./build/pkg.js",
13
+ "build": "oipage-cli --delete ./lib && node ./build/pkg.js",
14
14
  "test": "karma start ./build/karma.config.js",
15
15
  "lint": "eslint src/**/*.ts --fix"
16
16
  },
@@ -56,7 +56,6 @@
56
56
  "@types/jasmine": "^4.3.1",
57
57
  "@typescript-eslint/eslint-plugin": "^6.14.0",
58
58
  "@typescript-eslint/parser": "^6.14.0",
59
- "devby": "^0.4.6",
60
59
  "eslint": "^8.56.0",
61
60
  "karma": "^6.3.10",
62
61
  "karma-chrome-launcher": "^3.1.0",
@@ -73,6 +72,6 @@
73
72
  "webpack-dev-server": "^4.7.4"
74
73
  },
75
74
  "dependencies": {
76
- "@oipage/core.js": "^0.1.0"
75
+ "oipage": "^0.1.0"
77
76
  }
78
77
  }
@@ -2,7 +2,7 @@ import type { arcCapType } from '../../../types/painterConfig'
2
2
 
3
3
  export default function (type?: string) {
4
4
 
5
- let special = {
5
+ const special = {
6
6
  // 文字大小
7
7
  "fontSize": 16,
8
8
 
@@ -22,7 +22,7 @@ export default function (type?: string) {
22
22
  "arcEndCap": <arcCapType>'butt'
23
23
  }
24
24
 
25
- let init = {
25
+ const init = {
26
26
  // 填充色或图案
27
27
  "fillStyle": 'black',
28
28
 
@@ -1,4 +1,4 @@
1
- let enhanceGradient = function (gradient: CanvasGradient, calcStop?: Function) {
1
+ const enhanceGradient = function (gradient: CanvasGradient, calcStop?: Function) {
2
2
  const enhanceGradient = {
3
3
  "value": function () {
4
4
  return gradient
@@ -411,13 +411,13 @@ class Painter {
411
411
  install(methods: {
412
412
  [key: string]: Function
413
413
  }): any {
414
- for (let key in methods) {
414
+ for (const key in methods) {
415
415
 
416
416
  if (key in this) {
417
417
  throw new Error("VISLite Canvas:Method already exists and cannot be overwritten.")
418
418
  } else {
419
419
  (this as any)[key] = (...args: any) => {
420
- let value = methods[key].apply(this, args)
420
+ const value = methods[key].apply(this, args)
421
421
  if (value != void 0) return value
422
422
  return this
423
423
  }
@@ -1,7 +1,7 @@
1
1
  import { initDefs } from './config'
2
2
  import { toNode, setAttribute } from "./tool"
3
3
 
4
- let enhanceGradient = function (gradient: SVGElement, gradientId: string) {
4
+ const enhanceGradient = function (gradient: SVGElement, gradientId: string) {
5
5
  const enhanceGradient = {
6
6
  "value": function () {
7
7
  return "url(#" + gradientId + ")";
@@ -1,60 +1,62 @@
1
- import type { default as TreeConfigType, rootType, childrenType, idType } from '../../../types/TreeConfig'
2
-
3
- /**
4
- * 根据配置的层次关系(配置的id,child,root)把原始数据变成内部结构,方便后期位置计算
5
- *
6
- * tempTree[id] = {
7
- * "data": 原始数据,
8
- * "pid": 父亲ID,
9
- * "id": 唯一标识ID,
10
- * "show": boolean,
11
- * "isOpen": boolean,
12
- * "children": [cid1、cid2、...]
13
- * }
14
- */
15
- export default (initTree: any, config: TreeConfigType) => {
16
- const tempTree: {
17
- [key: string]: any
18
- } = {}
19
-
20
- // 根结点
21
- const temp = (config.root as rootType)(initTree)
22
- let id: number | string, rid: number | string
23
- id = rid = (config.id as idType)(temp)
24
- tempTree[id] = {
25
- "data": temp,
26
- "pid": null,
27
- "id": id,
28
- "isOpen": true,
29
- "show": true,
30
- "children": []
31
- }
32
-
33
- let num: number = 1
34
-
35
- // 根据传递的原始数据,生成内部统一结构
36
- ; (function createTree(pdata: any, pid: number | string) {
37
- const children = (config.children as childrenType)(pdata, initTree)
38
- num += children ? children.length : 0
39
- for (let flag = 0; children && flag < children.length; flag++) {
40
- id = (config.id as idType)(children[flag])
41
- tempTree[pid].children.push(id);
42
- tempTree[id] = {
43
- "data": children[flag],
44
- "pid": pid,
45
- "id": id,
46
- "isOpen": true,
47
- "show": true,
48
- "children": []
49
- }
50
- createTree(children[flag], id)
51
- }
52
- })(temp, id)
53
-
54
- return {
55
- rid,
56
- value: tempTree,
57
- num
58
- }
59
-
1
+ import type { default as TreeConfigType, rootType, childrenType, idType } from '../../../types/TreeConfig'
2
+
3
+ /**
4
+ * 根据配置的层次关系(配置的id,child,root)把原始数据变成内部结构,方便后期位置计算
5
+ *
6
+ * tempTree[id] = {
7
+ * "data": 原始数据,
8
+ * "pid": 父亲ID,
9
+ * "id": 唯一标识ID,
10
+ * "show": boolean,
11
+ * "isOpen": boolean,
12
+ * "children": [cid1、cid2、...]
13
+ * }
14
+ */
15
+ export default (initTree: any, config: TreeConfigType) => {
16
+ const tempTree: {
17
+ [key: string]: any
18
+ } = {}
19
+
20
+ // 根结点
21
+ const temp = (config.root as rootType)(initTree)
22
+ let id: number | string, rid: number | string
23
+ id = rid = (config.id as idType)(temp)
24
+ tempTree[id] = {
25
+ "data": temp,
26
+ "pid": null,
27
+ "id": id,
28
+ "isOpen": true,
29
+ "show": true,
30
+ "deg": 0,
31
+ "children": []
32
+ }
33
+
34
+ let num: number = 1
35
+
36
+ // 根据传递的原始数据,生成内部统一结构
37
+ ; (function createTree(pdata: any, pid: number | string) {
38
+ const children = (config.children as childrenType)(pdata, initTree)
39
+ num += children ? children.length : 0
40
+ for (let flag = 0; children && flag < children.length; flag++) {
41
+ id = (config.id as idType)(children[flag])
42
+ tempTree[pid].children.push(id);
43
+ tempTree[id] = {
44
+ "data": children[flag],
45
+ "pid": pid,
46
+ "id": id,
47
+ "isOpen": true,
48
+ "show": true,
49
+ "deg": 0,
50
+ "children": []
51
+ }
52
+ createTree(children[flag], id)
53
+ }
54
+ })(temp, id)
55
+
56
+ return {
57
+ rid,
58
+ value: tempTree,
59
+ num
60
+ }
61
+
60
62
  }
@@ -1,4 +1,4 @@
1
- let toString = Object.prototype.toString
1
+ const toString = Object.prototype.toString
2
2
 
3
3
  // 获取一个值的类型字符串[object type]
4
4
  export function getType(value: any) {
@@ -1,189 +1,195 @@
1
- import type TreeLayoutType from '../../types/TreeLayout'
2
- import type { TreeResultType } from '../../types/Tree'
3
- import type TreeOptionType from '../../types/TreeOption'
4
-
5
- import Tree from '../common/tree/index'
6
- import { initOption } from '../common/option'
7
- import { animation } from "@oipage/core.js/src/animation/index"
8
- import rotate from '../rotate'
9
-
10
- class TreeLayout extends Tree implements TreeLayoutType {
11
- readonly name: string = 'TreeLayout'
12
-
13
- private __option = {
14
- offsetX: 0,
15
- offsetY: 0,
16
- duration: 500,
17
- type: "plain",
18
- direction: "LR",
19
- x: 100,
20
- y: 100,
21
- width: 100,
22
- height: 100,
23
- radius: 100
24
- }
25
-
26
- private __rback: (tree: TreeResultType) => void
27
- private __oralTree: any
28
- private __preTree: TreeResultType | null
29
-
30
- private __noOpens = {}
31
-
32
- setOption(option: TreeOptionType) {
33
- initOption(option, this.__option)
34
- return this
35
- }
36
-
37
- use(initTree: any, noOpens = {}) {
38
- const tree = super.use(initTree, noOpens)
39
-
40
- // 校对偏差
41
- if (this.__option.offsetX != 0 || this.__option.offsetY != 0) {
42
- for (const key in tree.node) {
43
- if (!tree.node[key].show) {
44
-
45
- let deep = 0, pid = key
46
- do {
47
- pid = tree.node[pid].pid
48
- deep++
49
- } while (!tree.node[pid].show)
50
-
51
- tree.node[key].left += this.__option.offsetX * deep
52
- tree.node[key].top += this.__option.offsetY * deep
53
- }
54
- }
55
- }
56
-
57
- if (this.__option.type == 'rect') {
58
- if (this.__option.direction == 'LR' || this.__option.direction == "RL") {
59
-
60
- const perW = this.__option.height / tree.size
61
- const perD = this.__option.width / (tree.deep - 1)
62
-
63
- const balanceW = this.__option.y - this.__option.height * 0.5
64
- const flag = this.__option.direction == 'LR' ? 1 : -1
65
-
66
- for (const key in tree.node) {
67
- if (tree.deep == 1) {
68
- tree.node[key].left = this.__option.x + this.__option.width * 0.5 * flag
69
- tree.node[key].top = this.__option.y
70
- } else {
71
- tree.node[key].left = this.__option.x + (tree.node[key].left - 0.5) * perD * flag
72
- tree.node[key].top = tree.node[key].top * perW + balanceW
73
- }
74
- }
75
- } else if (this.__option.direction == 'TB' || this.__option.direction == "BT") {
76
-
77
- const perW = this.__option.width / tree.size
78
- const perD = this.__option.height / (tree.deep - 1)
79
-
80
- const balanceW = this.__option.x - this.__option.width * 0.5
81
- const flag = this.__option.direction == 'TB' ? 1 : -1
82
-
83
- for (const key in tree.node) {
84
- if (tree.deep == 1) {
85
- tree.node[key].left = this.__option.x
86
- tree.node[key].top = this.__option.y + this.__option.height * 0.5 * flag
87
- } else {
88
- const left = tree.node[key].left
89
-
90
- tree.node[key].left = tree.node[key].top * perW + balanceW
91
- tree.node[key].top = this.__option.y + (left - 0.5) * perD * flag
92
- }
93
- }
94
-
95
- }
96
-
97
- } else if (this.__option.type == 'circle') {
98
- const cx = this.__option.x, cy = this.__option.y
99
- const deg = Math.PI * 2 / tree.size
100
- const per = this.__option.radius / (tree.deep - 1)
101
-
102
- for (const key in tree.node) {
103
- if (tree.node[key].left == 0.5) {
104
- tree.node[key].left = cx
105
- tree.node[key].top = cy
106
- } else {
107
- const position = rotate(cx, cy, deg * tree.node[key].top, cx + (tree.node[key].left - 0.5) * per, cy)
108
-
109
- tree.node[key].left = position[0]
110
- tree.node[key].top = position[1]
111
- }
112
- }
113
- }
114
-
115
- return tree
116
- }
117
-
118
- bind(initTree: any, renderBack: (tree: TreeResultType) => void, noOpens = {}) {
119
- this.__rback = renderBack
120
- this.__oralTree = initTree
121
- this.__noOpens = noOpens
122
-
123
- this.__preTree = this.use(this.__oralTree, this.__noOpens)
124
- this.__rback(this.__preTree)
125
-
126
- return this
127
- }
128
-
129
- unbind() {
130
- this.__rback = () => null
131
- this.__oralTree = null
132
- this.__preTree = null
133
- this.__noOpens = {}
134
- return this
135
- }
136
-
137
- private doUpdate() {
138
- const newTree = this.use(this.__oralTree, this.__noOpens)
139
-
140
- const cacheTree = JSON.parse(JSON.stringify(newTree))
141
-
142
- animation((deep) => {
143
-
144
- if (this.__preTree) {
145
- for (const key in cacheTree.node) {
146
- if (newTree.node[key].show || this.__preTree.node[key].show) {
147
- cacheTree.node[key].show = true
148
-
149
- cacheTree.node[key].left = this.__preTree.node[key].left + (newTree.node[key].left - this.__preTree.node[key].left) * deep
150
- cacheTree.node[key].top = this.__preTree.node[key].top + (newTree.node[key].top - this.__preTree.node[key].top) * deep
151
- }
152
- }
153
- }
154
- this.__rback(cacheTree)
155
-
156
-
157
- }, this.__option.duration, () => {
158
- this.__preTree = newTree
159
- this.__rback(this.__preTree)
160
- })
161
- }
162
-
163
- closeNode(id: string) {
164
- if (!this.__preTree) return this
165
- this.__noOpens[id] = true
166
-
167
- this.doUpdate()
168
- return this
169
- }
170
-
171
- openNode(id: string) {
172
- if (!this.__preTree) return this
173
- this.__noOpens[id] = false
174
-
175
- this.doUpdate()
176
- return this
177
- }
178
-
179
- toggleNode(id: string) {
180
- if (!this.__preTree) return this
181
- this.__noOpens[id] = !this.__noOpens[id]
182
-
183
- this.doUpdate()
184
- return this
185
- }
186
-
187
- }
188
-
1
+ import type TreeLayoutType from '../../types/TreeLayout'
2
+ import type { TreeResultType } from '../../types/Tree'
3
+ import type TreeOptionType from '../../types/TreeOption'
4
+
5
+ import Tree from '../common/tree/index'
6
+ import { initOption } from '../common/option'
7
+ import { animation } from "oipage/corejs/animation/index"
8
+ import rotate from '../rotate'
9
+
10
+ class TreeLayout extends Tree implements TreeLayoutType {
11
+ readonly name: string = 'TreeLayout'
12
+
13
+ private __option = {
14
+ offsetX: 0,
15
+ offsetY: 0,
16
+ duration: 500,
17
+ type: "plain",
18
+ direction: "LR",
19
+ x: 100,
20
+ y: 100,
21
+ width: 100,
22
+ height: 100,
23
+ radius: 100
24
+ }
25
+
26
+ private __rback: (tree: TreeResultType) => void
27
+ private __oralTree: any
28
+ private __preTree: TreeResultType | null
29
+
30
+ private __noOpens = {}
31
+
32
+ setOption(option: TreeOptionType) {
33
+ initOption(option, this.__option)
34
+ return this
35
+ }
36
+
37
+ use(initTree: any, noOpens = {}) {
38
+ const tree = super.use(initTree, noOpens)
39
+
40
+ // 校对偏差
41
+ if (this.__option.offsetX != 0 || this.__option.offsetY != 0) {
42
+ for (const key in tree.node) {
43
+ if (!tree.node[key].show) {
44
+
45
+ let deep = 0, pid = key
46
+ do {
47
+ pid = tree.node[pid].pid
48
+ deep++
49
+ } while (!tree.node[pid].show)
50
+
51
+ tree.node[key].left += this.__option.offsetX * deep
52
+ tree.node[key].top += this.__option.offsetY * deep
53
+ }
54
+ }
55
+ }
56
+
57
+ if (this.__option.type == 'rect') {
58
+ if (this.__option.direction == 'LR' || this.__option.direction == "RL") {
59
+
60
+ const perW = this.__option.height / tree.size
61
+ const perD = this.__option.width / (tree.deep - 1)
62
+
63
+ const balanceW = this.__option.y - this.__option.height * 0.5
64
+ const flag = this.__option.direction == 'LR' ? 1 : -1
65
+
66
+ for (const key in tree.node) {
67
+ if (tree.deep == 1) {
68
+ tree.node[key].left = this.__option.x + this.__option.width * 0.5 * flag
69
+ tree.node[key].top = this.__option.y
70
+ } else {
71
+ tree.node[key].left = this.__option.x + (tree.node[key].left - 0.5) * perD * flag
72
+ tree.node[key].top = tree.node[key].top * perW + balanceW
73
+ }
74
+ }
75
+ } else if (this.__option.direction == 'TB' || this.__option.direction == "BT") {
76
+
77
+ const perW = this.__option.width / tree.size
78
+ const perD = this.__option.height / (tree.deep - 1)
79
+
80
+ const balanceW = this.__option.x - this.__option.width * 0.5
81
+ const flag = this.__option.direction == 'TB' ? 1 : -1
82
+
83
+
84
+
85
+ for (const key in tree.node) {
86
+ tree.node[key].deg = this.__option.direction == 'TB' ? Math.PI * 0.5 : Math.PI * -0.5
87
+
88
+ if (tree.deep == 1) {
89
+ tree.node[key].left = this.__option.x
90
+ tree.node[key].top = this.__option.y + this.__option.height * 0.5 * flag
91
+ } else {
92
+ const left = tree.node[key].left
93
+ tree.node[key].left = tree.node[key].top * perW + balanceW
94
+ tree.node[key].top = this.__option.y + (left - 0.5) * perD * flag
95
+ }
96
+ }
97
+
98
+ }
99
+
100
+ } else if (this.__option.type == 'circle') {
101
+ const cx = this.__option.x, cy = this.__option.y
102
+ const deg = Math.PI * 2 / tree.size
103
+ const per = this.__option.radius / (tree.deep - 1)
104
+
105
+ for (const key in tree.node) {
106
+ if (tree.node[key].left == 0.5) {
107
+ tree.node[key].left = cx
108
+ tree.node[key].top = cy
109
+ } else {
110
+ const position = rotate(cx, cy, deg * tree.node[key].top, cx + (tree.node[key].left - 0.5) * per, cy)
111
+
112
+ tree.node[key].deg = deg * tree.node[key].top
113
+ tree.node[key].left = position[0]
114
+ tree.node[key].top = position[1]
115
+ }
116
+ }
117
+ }
118
+
119
+ return tree
120
+ }
121
+
122
+ bind(initTree: any, renderBack: (tree: TreeResultType) => void, noOpens = {}) {
123
+ this.__rback = renderBack
124
+ this.__oralTree = initTree
125
+ this.__noOpens = noOpens
126
+
127
+ this.__preTree = this.use(this.__oralTree, this.__noOpens)
128
+ this.__rback(this.__preTree)
129
+
130
+ return this
131
+ }
132
+
133
+ unbind() {
134
+ this.__rback = () => null
135
+ this.__oralTree = null
136
+ this.__preTree = null
137
+ this.__noOpens = {}
138
+ return this
139
+ }
140
+
141
+ doUpdate() {
142
+ const newTree = this.use(this.__oralTree, this.__noOpens)
143
+
144
+ const cacheTree = JSON.parse(JSON.stringify(newTree))
145
+
146
+ animation((deep) => {
147
+
148
+ if (this.__preTree) {
149
+ for (const key in cacheTree.node) {
150
+ if (newTree.node[key].show || this.__preTree.node[key].show) {
151
+ cacheTree.node[key].show = true
152
+
153
+ cacheTree.node[key].left = this.__preTree.node[key].left + (newTree.node[key].left - this.__preTree.node[key].left) * deep
154
+ cacheTree.node[key].top = this.__preTree.node[key].top + (newTree.node[key].top - this.__preTree.node[key].top) * deep
155
+ }
156
+ }
157
+ }
158
+ this.__rback(cacheTree)
159
+
160
+
161
+ }, this.__option.duration, () => {
162
+ this.__preTree = newTree
163
+ this.__rback(this.__preTree)
164
+ })
165
+
166
+ return this
167
+ }
168
+
169
+ closeNode(id: string) {
170
+ if (!this.__preTree) return this
171
+ this.__noOpens[id] = true
172
+
173
+ this.doUpdate()
174
+ return this
175
+ }
176
+
177
+ openNode(id: string) {
178
+ if (!this.__preTree) return this
179
+ this.__noOpens[id] = false
180
+
181
+ this.doUpdate()
182
+ return this
183
+ }
184
+
185
+ toggleNode(id: string) {
186
+ if (!this.__preTree) return this
187
+ this.__noOpens[id] = !this.__noOpens[id]
188
+
189
+ this.doUpdate()
190
+ return this
191
+ }
192
+
193
+ }
194
+
189
195
  export default TreeLayout