vislite 1.2.0-alpha.1 → 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 -166
- package/lib/Buffer/index.es.js +1 -1
- package/lib/Buffer/index.es.min.js +1 -1
- package/lib/Canvas/index.es.js +5 -5
- package/lib/Canvas/index.es.min.js +1 -1
- 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 +48 -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 +2 -2
- package/src/animation.ts +98 -98
- 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/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,5 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* mergeOption of VISLite JavaScript Library v1.2.0-alpha.2
|
|
3
|
+
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
|
+
*/
|
|
5
|
+
var t=Object.prototype.toString;function e(e){if(null===e||"object"!=typeof e||"[object Object]"!=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":t.call(e)}(e))return!1;if(null===Object.getPrototypeOf(e))return!0;for(var o=e;null!==Object.getPrototypeOf(o);)o=Object.getPrototypeOf(o);return Object.getPrototypeOf(e)===o}function o(t,o){!function t(o,r){for(var n in r){var c=r[n];e(c)?(o[n]||(o[n]={}),t(o[n],r[n])):o[n]=c}}(t,o)}export{o as default};
|
package/lib/move/index.es.js
CHANGED
package/lib/move/index.es.min.js
CHANGED
package/lib/rotate/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* rotate of VISLite JavaScript Library v1.2.0-alpha.
|
|
2
|
+
* rotate of VISLite JavaScript Library v1.2.0-alpha.2
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*/
|
|
5
5
|
function t(t,a,n,r,e){var o=Math.cos(n),s=Math.sin(n);return[(r-t)*o-(e-a)*s+t,(r-t)*s+(e-a)*o+a]}export{t as default};
|
package/lib/ruler/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* ruler of VISLite JavaScript Library v1.2.0-alpha.
|
|
2
|
+
* ruler of VISLite JavaScript Library v1.2.0-alpha.2
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*/
|
|
5
5
|
function n(n,r,t,e){if(n<r){var i=r;r=n,n=i}else if(n==r)return[n];var a=function(n){for(var r=n<100&&n>-100?10:.1,t=-1,e=n;10==r?e>=-100&&e<=100:e<=-100||e>=100;)t+=1,e*=r;if(10==r)return Math.pow(10,t);for(var i="0.",a=1;a<t;a++)i+="0";return+(i+"1")}(n-r),u=Math.ceil((n-r)*a/t),f=function(t){var e=({3:2,4:5,6:5,7:5,8:10,9:10,11:10,12:10,13:15,14:15,16:15,17:15,18:20,19:20,21:20,22:20,23:25,24:25,26:25,27:25}[u+t]||u+t)/a,i=Math.floor(r/e)*e,f=[];f.push(i);for(var l=1;f[f.length-1]<n;l++)f.push(i+e*l);return f},l=f(0),o=function(){for(var n=[],t=l[l.length-1]-(null==e?void 0:e.max),i=0;i<l.length;i++)i+1<l.length&&l[i+1]-t<r||n.push(l[i]-t);return n},h=function(){for(var r=[],t=l[0]-(null==e?void 0:e.min),i=0;i<l.length&&(r[i]=l[i]-t,!(n<=r[i]));i++);return r};if(e){if("max"in e&&"min"in e&&e.max>=n&&e.min<=r){var m=function(){if(l[0]>=e.min&&l[l.length-1]<=e.max)return!0;var n=o();if(n[0]>=e.min&&n[n.length-1]<=e.max)return l=n,!0;var r=h();return r[0]>=e.min&&r[n.length-1]<=e.max?(l=r,!0):void 0};if(m())return l;for(var v=1;v<100;v++){if(l=f(v),m())return l;if(l=f(-v),m())return l}}"max"in e&&e.max>=n?e.max<l[l.length-1]&&(l=o()):"min"in e&&e.min<=r&&e.min>l[0]&&(l=h())}for(var g=0;g<l.length;g++){var s=l[g]+"";/\./.test(s)&&(/9{7,}$/.test(s)?(s=s.replace(/9{7,}$/,""),l[g]=+(s.substring(0,s.length-1)+(+s[s.length-1]+1))):/0{7,}\d$/.test(s)&&(l[g]=+s.replace(/0{7,}\d$/,"")))}return l}export{n as default};
|
package/lib/scale/index.es.js
CHANGED
package/lib/throttle/index.es.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* throttle of VISLite JavaScript Library v1.2.0-alpha.
|
|
2
|
+
* throttle of VISLite JavaScript Library v1.2.0-alpha.2
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*/
|
|
5
|
-
function
|
|
6
|
-
for (var key in
|
|
7
|
-
defaultOption[key] =
|
|
5
|
+
function initOption(setOption, defaultOption) {
|
|
6
|
+
for (var key in setOption) {
|
|
7
|
+
defaultOption[key] = setOption[key];
|
|
8
8
|
}
|
|
9
9
|
return defaultOption;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
function throttle (callback, option) {
|
|
13
13
|
if (option === void 0) { option = {}; }
|
|
14
|
-
option =
|
|
14
|
+
option = initOption(option, {
|
|
15
15
|
time: 200,
|
|
16
16
|
keep: false,
|
|
17
17
|
opportunity: "end"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* throttle of VISLite JavaScript Library v1.2.0-alpha.
|
|
2
|
+
* throttle of VISLite JavaScript Library v1.2.0-alpha.2
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*/
|
|
5
5
|
function t(t,n){void 0===n&&(n={}),n=function(t,n){for(var e in t)n[e]=t[e];return n}(n,{time:200,keep:!1,opportunity:"end"});var e,p=!1,r=!1,i=!1;return function(){var o=this;if(e=arguments,p)r=!0,i=!0;else{"end"!=n.opportunity&&t.apply(o,e),p=!0;var a=setInterval((function(){r?n.keep||t.apply(o,e):("begin"!=n.opportunity&&(i||"end"==n.opportunity)&&t.apply(o,e),p=!1,i=!1,clearInterval(a)),r=!1}),n.time)}}}export{t as default};
|
package/package/index.ts
CHANGED
|
@@ -26,6 +26,11 @@ import throttle from "./throttle/index"
|
|
|
26
26
|
|
|
27
27
|
import TreeLayout from "./TreeLayout/index"
|
|
28
28
|
|
|
29
|
+
import initOption from "./initOption/index"
|
|
30
|
+
import mergeOption from "./mergeOption/index"
|
|
31
|
+
|
|
32
|
+
import assemble from "./assemble/index"
|
|
33
|
+
|
|
29
34
|
export default {
|
|
30
35
|
|
|
31
36
|
// 插值
|
|
@@ -60,7 +65,12 @@ export default {
|
|
|
60
65
|
|
|
61
66
|
// 辅助
|
|
62
67
|
throttle,
|
|
68
|
+
assemble,
|
|
63
69
|
|
|
64
70
|
// 布局
|
|
65
|
-
TreeLayout
|
|
71
|
+
TreeLayout,
|
|
72
|
+
|
|
73
|
+
// 配置项
|
|
74
|
+
initOption,
|
|
75
|
+
mergeOption
|
|
66
76
|
}
|
package/package.json
CHANGED
package/src/Canvas.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type CanvasType from '../types/Canvas'
|
|
|
2
2
|
import type CanvasOptionType from '../types/CanvasOption'
|
|
3
3
|
|
|
4
4
|
import OralCanvas from './common/canvas/index'
|
|
5
|
-
import
|
|
5
|
+
import { initOption } from './common/option'
|
|
6
6
|
|
|
7
7
|
class Canvas extends OralCanvas implements CanvasType {
|
|
8
8
|
private __canvas: HTMLCanvasElement
|
|
@@ -12,7 +12,7 @@ class Canvas extends OralCanvas implements CanvasType {
|
|
|
12
12
|
throw new Error("VISLite Canvas:The mount point requires an HTMLElement type but encountered null.")
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
option =
|
|
15
|
+
option = initOption(option, {
|
|
16
16
|
region: true,
|
|
17
17
|
willReadFrequently: false
|
|
18
18
|
})
|
package/src/animation.ts
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
//当前正在运动的动画的tick函数堆栈
|
|
2
|
-
let $timers: any[] = []
|
|
3
|
-
//唯一定时器的定时间隔
|
|
4
|
-
const $interval = 13
|
|
5
|
-
//定时器ID
|
|
6
|
-
let $timerId: any
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 动画轮播
|
|
10
|
-
* @param {function} doback 轮询函数,有一个形参deep,0-1,表示执行进度
|
|
11
|
-
* @param {number} duration 动画时长,可选
|
|
12
|
-
* @param {function} callback 动画结束回调,可选,有一个形参deep,0-1,表示执行进度
|
|
13
|
-
*
|
|
14
|
-
* @returns {function} 返回一个函数,调用该函数,可以提前结束动画
|
|
15
|
-
*/
|
|
16
|
-
export default function (doback: (deep: number) => void, duration: number = 400, callback: (deep: number) => void = () => { }): Function {
|
|
17
|
-
|
|
18
|
-
const clock = {
|
|
19
|
-
//把tick函数推入堆栈
|
|
20
|
-
"timer": function (tick: (deep: number) => void, duration: number, callback: (deep: number) => void) {
|
|
21
|
-
if (!tick) {
|
|
22
|
-
throw new Error('Tick is required!')
|
|
23
|
-
}
|
|
24
|
-
const id = new Date().valueOf() + "_" + (Math.random() * 1000).toFixed(0)
|
|
25
|
-
$timers.push({
|
|
26
|
-
"id": id,
|
|
27
|
-
"createTime": new Date(),
|
|
28
|
-
"tick": tick,
|
|
29
|
-
"duration": duration,
|
|
30
|
-
"callback": callback
|
|
31
|
-
})
|
|
32
|
-
clock.start()
|
|
33
|
-
return id
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
//开启唯一的定时器timerId
|
|
37
|
-
"start": function () {
|
|
38
|
-
if (!$timerId) {
|
|
39
|
-
$timerId = setInterval(clock.tick, $interval)
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
//被定时器调用,遍历timers堆栈
|
|
44
|
-
"tick": function () {
|
|
45
|
-
let createTime: Date, flag: number, tick: (deep: number) => void, callback: (deep: number) => void, timer: any, duration: number, passTime: number
|
|
46
|
-
const timers: any[] = $timers
|
|
47
|
-
$timers = []
|
|
48
|
-
$timers.length = 0
|
|
49
|
-
for (flag = 0; flag < timers.length; flag++) {
|
|
50
|
-
//初始化数据
|
|
51
|
-
timer = timers[flag]
|
|
52
|
-
createTime = timer.createTime
|
|
53
|
-
tick = timer.tick
|
|
54
|
-
duration = timer.duration
|
|
55
|
-
callback = timer.callback
|
|
56
|
-
|
|
57
|
-
//执行
|
|
58
|
-
passTime = (+new Date().valueOf() - createTime.valueOf()) / duration
|
|
59
|
-
passTime = passTime > 1 ? 1 : passTime
|
|
60
|
-
tick(passTime)
|
|
61
|
-
if (passTime < 1 && timer.id) {
|
|
62
|
-
//动画没有结束再添加
|
|
63
|
-
$timers.push(timer)
|
|
64
|
-
} else {
|
|
65
|
-
callback(passTime)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if ($timers.length <= 0) {
|
|
69
|
-
clock.stop()
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
//停止定时器,重置timerId=null
|
|
74
|
-
"stop": function () {
|
|
75
|
-
if ($timerId) {
|
|
76
|
-
clearInterval($timerId)
|
|
77
|
-
$timerId = null
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const id = clock.timer(function (deep: number) {
|
|
83
|
-
//其中deep为0-1,表示改变的程度
|
|
84
|
-
doback(deep)
|
|
85
|
-
}, duration, callback)
|
|
86
|
-
|
|
87
|
-
// 返回一个函数
|
|
88
|
-
// 用于在动画结束前结束动画
|
|
89
|
-
return function () {
|
|
90
|
-
let i: string
|
|
91
|
-
for (i in $timers) {
|
|
92
|
-
if ($timers[i].id == id) {
|
|
93
|
-
$timers[i].id = void 0
|
|
94
|
-
return
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
1
|
+
//当前正在运动的动画的tick函数堆栈
|
|
2
|
+
let $timers: any[] = []
|
|
3
|
+
//唯一定时器的定时间隔
|
|
4
|
+
const $interval = 13
|
|
5
|
+
//定时器ID
|
|
6
|
+
let $timerId: any
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 动画轮播
|
|
10
|
+
* @param {function} doback 轮询函数,有一个形参deep,0-1,表示执行进度
|
|
11
|
+
* @param {number} duration 动画时长,可选
|
|
12
|
+
* @param {function} callback 动画结束回调,可选,有一个形参deep,0-1,表示执行进度
|
|
13
|
+
*
|
|
14
|
+
* @returns {function} 返回一个函数,调用该函数,可以提前结束动画
|
|
15
|
+
*/
|
|
16
|
+
export default function (doback: (deep: number) => void, duration: number = 400, callback: (deep: number) => void = () => { }): Function {
|
|
17
|
+
|
|
18
|
+
const clock = {
|
|
19
|
+
//把tick函数推入堆栈
|
|
20
|
+
"timer": function (tick: (deep: number) => void, duration: number, callback: (deep: number) => void) {
|
|
21
|
+
if (!tick) {
|
|
22
|
+
throw new Error('Tick is required!')
|
|
23
|
+
}
|
|
24
|
+
const id = new Date().valueOf() + "_" + (Math.random() * 1000).toFixed(0)
|
|
25
|
+
$timers.push({
|
|
26
|
+
"id": id,
|
|
27
|
+
"createTime": new Date(),
|
|
28
|
+
"tick": tick,
|
|
29
|
+
"duration": duration,
|
|
30
|
+
"callback": callback
|
|
31
|
+
})
|
|
32
|
+
clock.start()
|
|
33
|
+
return id
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
//开启唯一的定时器timerId
|
|
37
|
+
"start": function () {
|
|
38
|
+
if (!$timerId) {
|
|
39
|
+
$timerId = setInterval(clock.tick, $interval)
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
//被定时器调用,遍历timers堆栈
|
|
44
|
+
"tick": function () {
|
|
45
|
+
let createTime: Date, flag: number, tick: (deep: number) => void, callback: (deep: number) => void, timer: any, duration: number, passTime: number
|
|
46
|
+
const timers: any[] = $timers
|
|
47
|
+
$timers = []
|
|
48
|
+
$timers.length = 0
|
|
49
|
+
for (flag = 0; flag < timers.length; flag++) {
|
|
50
|
+
//初始化数据
|
|
51
|
+
timer = timers[flag]
|
|
52
|
+
createTime = timer.createTime
|
|
53
|
+
tick = timer.tick
|
|
54
|
+
duration = timer.duration
|
|
55
|
+
callback = timer.callback
|
|
56
|
+
|
|
57
|
+
//执行
|
|
58
|
+
passTime = (+new Date().valueOf() - createTime.valueOf()) / duration
|
|
59
|
+
passTime = passTime > 1 ? 1 : passTime
|
|
60
|
+
tick(passTime)
|
|
61
|
+
if (passTime < 1 && timer.id) {
|
|
62
|
+
//动画没有结束再添加
|
|
63
|
+
$timers.push(timer)
|
|
64
|
+
} else {
|
|
65
|
+
callback(passTime)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if ($timers.length <= 0) {
|
|
69
|
+
clock.stop()
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
//停止定时器,重置timerId=null
|
|
74
|
+
"stop": function () {
|
|
75
|
+
if ($timerId) {
|
|
76
|
+
clearInterval($timerId)
|
|
77
|
+
$timerId = null
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const id = clock.timer(function (deep: number) {
|
|
83
|
+
//其中deep为0-1,表示改变的程度
|
|
84
|
+
doback(deep)
|
|
85
|
+
}, duration, callback)
|
|
86
|
+
|
|
87
|
+
// 返回一个函数
|
|
88
|
+
// 用于在动画结束前结束动画
|
|
89
|
+
return function () {
|
|
90
|
+
let i: string
|
|
91
|
+
for (i in $timers) {
|
|
92
|
+
if ($timers[i].id == id) {
|
|
93
|
+
$timers[i].id = void 0
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
99
|
}
|
|
@@ -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"
|
package/types/index.d.ts
CHANGED
|
@@ -23,10 +23,13 @@ import TextureType from './Texture'
|
|
|
23
23
|
import MapType from './Map'
|
|
24
24
|
|
|
25
25
|
import throttleType from './throttle'
|
|
26
|
+
import assembleType from './assemble'
|
|
26
27
|
|
|
27
28
|
import TreeLayoutType from './TreeLayout'
|
|
28
29
|
import TreeConfigType from './TreeConfig'
|
|
29
30
|
|
|
31
|
+
import { initOptionType, mergeOptionType } from './option'
|
|
32
|
+
|
|
30
33
|
// 插值
|
|
31
34
|
interface NewCardinalType extends CardinalType {
|
|
32
35
|
new(t?: number): this
|
|
@@ -105,9 +108,14 @@ export default class VISLite {
|
|
|
105
108
|
|
|
106
109
|
// 辅助
|
|
107
110
|
static throttle: throttleType
|
|
111
|
+
static assemble: assembleType
|
|
108
112
|
|
|
109
113
|
// 布局
|
|
110
114
|
static TreeLayout: NewTreeLayoutType
|
|
115
|
+
|
|
116
|
+
// 配置项
|
|
117
|
+
static initOption: initOptionType
|
|
118
|
+
static mergeOption: mergeOptionType
|
|
111
119
|
}
|
|
112
120
|
|
|
113
121
|
// 插值
|
|
@@ -141,6 +149,11 @@ export let Mercator: NewMercatorType
|
|
|
141
149
|
|
|
142
150
|
// 辅助
|
|
143
151
|
export let throttle: throttleType
|
|
152
|
+
export let assemble: assembleType
|
|
144
153
|
|
|
145
154
|
// 布局
|
|
146
|
-
export let TreeLayout: NewTreeLayoutType
|
|
155
|
+
export let TreeLayout: NewTreeLayoutType
|
|
156
|
+
|
|
157
|
+
// 配置项
|
|
158
|
+
export let initOption: initOptionType
|
|
159
|
+
export let mergeOption: mergeOptionType
|