vislite 1.2.0-alpha.0 → 1.2.0-alpha.2
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.
- package/CHANGELOG +5 -1
- package/README.md +165 -142
- package/lib/Buffer/index.es.js +1 -1
- package/lib/Buffer/index.es.min.js +1 -1
- package/lib/Canvas/index.es.js +15 -5
- package/lib/Canvas/index.es.min.js +2 -2
- package/lib/Cardinal/index.es.js +1 -1
- package/lib/Cardinal/index.es.min.js +1 -1
- package/lib/Eoap/index.es.js +1 -1
- package/lib/Eoap/index.es.min.js +1 -1
- package/lib/Hermite/index.es.js +1 -1
- package/lib/Hermite/index.es.min.js +1 -1
- package/lib/Matrix4/index.es.js +1 -1
- package/lib/Matrix4/index.es.min.js +1 -1
- package/lib/Mercator/index.es.js +1 -1
- package/lib/Mercator/index.es.min.js +1 -1
- package/lib/RawCanvas/index.es.js +1 -1
- package/lib/RawCanvas/index.es.min.js +1 -1
- package/lib/SVG/index.es.js +1 -1
- package/lib/SVG/index.es.min.js +1 -1
- package/lib/Shader/index.es.js +1 -1
- package/lib/Shader/index.es.min.js +1 -1
- package/lib/Texture/index.es.js +1 -1
- package/lib/Texture/index.es.min.js +1 -1
- package/lib/TreeLayout/index.es.js +6 -6
- package/lib/TreeLayout/index.es.min.js +1 -1
- package/lib/animation/index.es.js +1 -1
- package/lib/animation/index.es.min.js +1 -1
- package/lib/assemble/index.es.d.ts +3 -0
- package/lib/assemble/index.es.js +23 -0
- package/lib/assemble/index.es.min.d.ts +3 -0
- package/lib/assemble/index.es.min.js +5 -0
- package/lib/getLoopColors/index.es.js +1 -1
- package/lib/getLoopColors/index.es.min.js +1 -1
- package/lib/getWebGLContext/index.es.js +1 -1
- package/lib/getWebGLContext/index.es.min.js +1 -1
- package/lib/index.umd.js +58 -9
- package/lib/index.umd.min.js +2 -2
- package/lib/initOption/index.es.d.ts +3 -0
- package/lib/initOption/index.es.js +12 -0
- package/lib/initOption/index.es.min.d.ts +3 -0
- package/lib/initOption/index.es.min.js +5 -0
- package/lib/mergeOption/index.es.d.ts +3 -0
- package/lib/mergeOption/index.es.js +42 -0
- package/lib/mergeOption/index.es.min.d.ts +3 -0
- package/lib/mergeOption/index.es.min.js +5 -0
- package/lib/move/index.es.js +1 -1
- package/lib/move/index.es.min.js +1 -1
- package/lib/rotate/index.es.js +1 -1
- package/lib/rotate/index.es.min.js +1 -1
- package/lib/ruler/index.es.js +1 -1
- package/lib/ruler/index.es.min.js +1 -1
- package/lib/scale/index.es.js +1 -1
- package/lib/scale/index.es.min.js +1 -1
- package/lib/throttle/index.es.js +5 -5
- package/lib/throttle/index.es.min.js +1 -1
- package/package/assemble/index.ts +3 -0
- package/package/index.ts +11 -1
- package/package/initOption/index.ts +3 -0
- package/package/mergeOption/index.ts +3 -0
- package/package.json +1 -1
- package/src/Canvas.ts +13 -2
- package/src/animation.ts +98 -98
- package/src/common/canvas/painter.ts +475 -475
- package/src/common/option.ts +30 -0
- package/src/common/tree/index.ts +2 -2
- package/src/common/type.ts +27 -0
- package/src/layout/TreeLayout.ts +2 -2
- package/src/throttle.ts +2 -2
- package/types/Canvas.d.ts +330 -331
- package/types/Matrix4.d.ts +1 -1
- package/types/assemble.d.ts +6 -0
- package/types/index.d.ts +14 -1
- package/types/option.d.ts +13 -0
- package/src/common/mergeOption.ts +0 -7
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isPlainObject } from "./type"
|
|
2
|
+
|
|
3
|
+
// 初始化配置
|
|
4
|
+
export function initOption(setOption: any, defaultOption: any) {
|
|
5
|
+
for (const key in setOption) {
|
|
6
|
+
defaultOption[key] = setOption[key]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return defaultOption
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// 合并配置
|
|
13
|
+
export function mergeOption(oldOption: any, newOption: any) {
|
|
14
|
+
(function doit(oldOption, newOption) {
|
|
15
|
+
|
|
16
|
+
for (const key in newOption) {
|
|
17
|
+
const value = newOption[key]
|
|
18
|
+
|
|
19
|
+
if (isPlainObject(value)) {
|
|
20
|
+
if (!oldOption[key]) oldOption[key] = {}
|
|
21
|
+
|
|
22
|
+
doit(oldOption[key], newOption[key])
|
|
23
|
+
} else {
|
|
24
|
+
oldOption[key] = value
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
})(oldOption, newOption)
|
|
30
|
+
}
|
package/src/common/tree/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type TreeConfigType from '../../../types/TreeConfig'
|
|
|
2
2
|
import type { TreeResultType } from '../../../types/Tree'
|
|
3
3
|
|
|
4
4
|
import toPlainTree from './toPlainTree'
|
|
5
|
-
import
|
|
5
|
+
import { initOption } from '../option'
|
|
6
6
|
|
|
7
7
|
class Tree {
|
|
8
8
|
readonly name: string = 'Tree'
|
|
@@ -10,7 +10,7 @@ class Tree {
|
|
|
10
10
|
private __config: TreeConfigType
|
|
11
11
|
|
|
12
12
|
constructor(config: TreeConfigType = {}) {
|
|
13
|
-
this.__config =
|
|
13
|
+
this.__config = initOption(config, {
|
|
14
14
|
root: (initTree: any) => initTree,
|
|
15
15
|
children: (parentTree: any) => parentTree.children,
|
|
16
16
|
id: (treedata: any) => treedata.name
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
let toString = Object.prototype.toString
|
|
2
|
+
|
|
3
|
+
// 获取一个值的类型字符串[object type]
|
|
4
|
+
export function getType(value: any) {
|
|
5
|
+
if (value == null) {
|
|
6
|
+
return value === undefined ? '[object Undefined]' : '[object Null]'
|
|
7
|
+
}
|
|
8
|
+
return toString.call(value)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// 判断一个值是不是一个朴素的'对象'
|
|
12
|
+
export function isPlainObject(value: any) {
|
|
13
|
+
if (value === null || typeof value !== 'object' || getType(value) != '[object Object]') {
|
|
14
|
+
return false
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 如果原型为null
|
|
18
|
+
if (Object.getPrototypeOf(value) === null) {
|
|
19
|
+
return true
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let proto = value
|
|
23
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
24
|
+
proto = Object.getPrototypeOf(proto)
|
|
25
|
+
}
|
|
26
|
+
return Object.getPrototypeOf(value) === proto
|
|
27
|
+
}
|
package/src/layout/TreeLayout.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { TreeResultType } from '../../types/Tree'
|
|
|
3
3
|
import type TreeOptionType from '../../types/TreeOption'
|
|
4
4
|
|
|
5
5
|
import Tree from '../common/tree/index'
|
|
6
|
-
import
|
|
6
|
+
import { initOption } from '../common/option'
|
|
7
7
|
import animation from '../animation'
|
|
8
8
|
import rotate from '../rotate'
|
|
9
9
|
|
|
@@ -30,7 +30,7 @@ class TreeLayout extends Tree implements TreeLayoutType {
|
|
|
30
30
|
private __noOpens = {}
|
|
31
31
|
|
|
32
32
|
setOption(option: TreeOptionType) {
|
|
33
|
-
|
|
33
|
+
initOption(option, this.__option)
|
|
34
34
|
return this
|
|
35
35
|
}
|
|
36
36
|
|
package/src/throttle.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type throttleOptionType from '../types/throttleOption'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { initOption } from './common/option'
|
|
4
4
|
|
|
5
5
|
export default function (callback: Function, option: throttleOptionType = {}) {
|
|
6
6
|
|
|
7
7
|
// 校对缺省值
|
|
8
|
-
option =
|
|
8
|
+
option = initOption(option, <throttleOptionType>{
|
|
9
9
|
time: 200,
|
|
10
10
|
keep: false,
|
|
11
11
|
opportunity: "end"
|