more semantic version

This commit is contained in:
Henry
2018-10-09 16:54:03 +08:00
committed by GitHub
parent e9b131b8e3
commit d5044d0501

View File

@ -19,14 +19,12 @@ const throttle = (fn, wait) => {
inThrottle = true;
} else {
clearTimeout(lastFn);
let time = 0;
lastFn = setTimeout(function() {
if (Date.now() - lastTime >= wait) {
fn.apply(context, args);
lastTime = Date.now();
}
time = wait - (Date.now() - lastTime)
}, time>0 ? time : 0);
}, Math.max(wait - (Date.now() - lastTime), 0));
}
};
};