From e13367edf304cb78f978e321f1679299a66b3a23 Mon Sep 17 00:00:00 2001
From: quanyawei <401863037@qq.com>
Date: Wed, 10 Jan 2024 16:08:18 +0800
Subject: [PATCH] fix:地图
---
uni_modules/uview-ui/libs/function/debounce.js | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/uni_modules/uview-ui/libs/function/debounce.js b/uni_modules/uview-ui/libs/function/debounce.js
new file mode 100644
index 0000000..ad3996b
--- /dev/null
+++ b/uni_modules/uview-ui/libs/function/debounce.js
@@ -0,0 +1,29 @@
+let timeout = null
+
+/**
+ * ������������������������������������������������������������������wait������������������������
+ *
+ * @param {Function} func ������������������������
+ * @param {Number} wait ���������������
+ * @param {Boolean} immediate ������������������
+ * @return null
+ */
+function debounce(func, wait = 500, immediate = false) {
+ // ���������������
+ if (timeout !== null) clearTimeout(timeout)
+ // ������������������������������������������
+ if (immediate) {
+ const callNow = !timeout
+ timeout = setTimeout(() => {
+ timeout = null
+ }, wait)
+ if (callNow) typeof func === 'function' && func()
+ } else {
+ // ���������������������������������������������timeout������������������������������������wait���������������func������������
+ timeout = setTimeout(() => {
+ typeof func === 'function' && func()
+ }, wait)
+ }
+}
+
+export default debounce
--
Gitblit v1.8.0