feat: add zone tooltip #367

This commit is contained in:
Hufe921
2023-12-22 21:34:48 +08:00
parent 57fdcb8b81
commit 095414fbe6
16 changed files with 183 additions and 2 deletions
+19
View File
@@ -12,6 +12,25 @@ export function debounce(func: Function, delay: number) {
}
}
export function throttle(func: Function, delay: number) {
let lastExecTime = 0
let timer: number
return function (this: any, ...args: any[]) {
const currentTime = Date.now()
if (currentTime - lastExecTime >= delay) {
window.clearTimeout(timer)
func.apply(this, args)
lastExecTime = currentTime
} else {
window.clearTimeout(timer)
timer = window.setTimeout(() => {
func.apply(this, args)
lastExecTime = currentTime
}, delay)
}
}
}
export function deepClone<T>(obj: T): T {
if (!obj || typeof obj !== 'object') {
return obj