优化代码

This commit is contained in:
Harvey Zack committed 2018-11-07 10:46:20 +08:00
1 parent d058fc318c
commit e0a2a2c594
25 files changed
+288 -172

No files matched your search

+7 -1
View File
@@ -120,7 +120,7 @@ export function sublings(target) {
export function debounce(func, wait, context) {
let timeout;
return function fn() {
function fn() {
const args = arguments;
const later = function later() {
timeout = null;
@@ -128,5 +128,11 @@ export function debounce(func, wait, context) {
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
}
fn.clearTimeout = function ct() {
clearTimeout(timeout);
};
return fn;
}