function testFn() { console.log(1111); }
var throttle = function (fn, delay,atleast) {
var timer = null;
var pretime = null;
return function () {
var now = Date.now()
if(!pretime) pretime = now;
if(now - pretime >atleast){
fn();
pretime = now;
}else{
clearTimeout(timer);
timer = setTimeout(function() {
fn();
}, delay);
}
}
};
throttle(testFn, 200,1000)()