cc-tools-utils 0.0.4 → 0.0.5
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/dist/img/Transform.d.ts +3 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1 -0
- package/dist/js/bus.d.ts +8 -0
- package/dist/js/cesiumHooks.d.ts +68 -0
- package/dist/js/tools.d.ts +2 -0
- package/dist/lib/img/Transform.d.ts +3 -0
- package/dist/lib/js/Anima.d.ts +2 -0
- package/dist/lib/js/bus.d.ts +9 -0
- package/dist/lib/js/cesiumHooks.d.ts +67 -0
- package/dist/lib/js/tools.d.ts +28 -0
- package/package.json +4 -10
- package/index.js +0 -12
- package/lib/img/Transform.ts +0 -44
- package/lib/js/cesiumHooks.js +0 -1127
- package/lib/js/tools.js +0 -36
package/lib/js/tools.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// 防抖函数
|
|
2
|
-
export const debounce = (time, fn) => {
|
|
3
|
-
if (typeof fn !== "function") {
|
|
4
|
-
throw new Error("debounce的第二个参数必须是函数");
|
|
5
|
-
}
|
|
6
|
-
if (typeof time !== "number" || time < 0) {
|
|
7
|
-
throw new Error("debounce的第一个参数必须是非负数");
|
|
8
|
-
}
|
|
9
|
-
let timeoutID = null;
|
|
10
|
-
return function () {
|
|
11
|
-
if (timeoutID) clearTimeout(timeoutID);
|
|
12
|
-
timeoutID = setTimeout(() => {
|
|
13
|
-
fn.apply(this, arguments);
|
|
14
|
-
timeoutID = null;
|
|
15
|
-
}, time);
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// 节流
|
|
20
|
-
export const throttle = (time, fn) => {
|
|
21
|
-
if (typeof fn !== "function") {
|
|
22
|
-
throw new Error("throttle的第二个参数必须是函数");
|
|
23
|
-
}
|
|
24
|
-
if (typeof time !== "number" || time < 0) {
|
|
25
|
-
throw new Error("throttle的第一个参数必须是非负数");
|
|
26
|
-
}
|
|
27
|
-
let isRunning = false;
|
|
28
|
-
return function () {
|
|
29
|
-
if (isRunning) return;
|
|
30
|
-
isRunning = true;
|
|
31
|
-
fn.apply(this, arguments);
|
|
32
|
-
setTimeout(() => {
|
|
33
|
-
isRunning = false;
|
|
34
|
-
}, time);
|
|
35
|
-
};
|
|
36
|
-
};
|