throttle¶
Methods¶
- KISSY.throttle()¶
- Boolean KISSY.throttle (fn, ms, context)ms 时间内只执行 fn 一次, 即使这段时间内 fn 被调用多次.
Parameters: - fn (Function) – 要缓存的函数;
- ms (Number) – 要缓存多长时间后执行, 默认是 150 ms;
- context (Object) – 函数 fn 要执行时的上下文环境, 默认是 this;
Returns: 返回缓存后的函数对象;
Return type: Function
Note
例如
function sayHi() { alert('hi'); } say = S.throttle(sayHi, 300, this); say(); // 忽略 S.later(say, 200); // 忽略 S.later(say, 350); // 超过300ms后, 终于执行