当前位置:网站首页>JS anti shake and throttling
JS anti shake and throttling
2022-07-01 02:24:00 【kilito_ 01】
/ Throttling function
function throttle(callback, wait) {
let start = 0 ;
return function(e){
let now = Date.now()
if(now - start >= wait){
callback.call(this,e);
start = now;
}
}
}
// Anti shake function
function debounce(callback,time){
var timeout = null;
return function(e){
if(timeout != null){
clearTimeout(timeout)
}
// Start timer
timeout = setTimeout(()=>{
callback.call(this,e)
timeout = null;
},time)
}
}
边栏推荐
猜你喜欢

QML control type: tooltip

删除重复的电子邮箱

CorelDRAW 2022 Chinese Simplified 64 bit direct download

SWT/ANR问题--StorageManagerService卡住

视觉特效,图片转成漫画功能

Zero foundation self-study SQL course | window function

halcon变量窗口的图像变量不显示,重启软件和电脑都没用

(translation) reasons why real-time inline verification is easier for users to make mistakes

如何在智汀中實現智能鎖與燈、智能窗簾電機場景聯動?

Rocketqa: cross batch negatives, de noised hard negative sampling and data augmentation
随机推荐
Static domain and static method
SWT / anr problem - binder stuck
SWT / anr problem - SWT caused by long execution time of native method
7_OpenResty安装
js中的图片预加载
Rocketqa: cross batch negatives, de noised hard negative sampling and data augmentation
零基础自学SQL课程 | 窗口函数
How does ZABBIX configure alarm SMS? (alert SMS notification setting process)
Is there any discount for opening an account now? In addition, is it safe to open a mobile account?
对象与对象变量
SWT / anr problem - SWT caused by too long dump time
开源基础软件公司,寻找一起创造未来的你(API7.ai)
import tensorflow.contrib.slim as slim报错
SWT/ANR问题--ANR/JE引发SWT
What is project management?
FL studio20.9 fruit software advanced Chinese edition electronic music arrangement
如何学习和阅读代码
Leetcode interview question 17.10 Main elements
How to learn and read code
SWT / anr problem - anr/je causes SWT