当前位置:网站首页>Simple understanding of anti shake function
Simple understanding of anti shake function
2022-06-12 19:40:00 【Hello^_^ Monkey】
// Shake proof : User triggered events too frequently , Only the operation of the last event is needed
const inp = document.querySelector("input");
// Encapsulate an anti shake function
inp.oninput = debounce(function () {
console.log(this.value);
}, 500);
function debounce(fn, delay) {
let t = null;
return function () {
if (t !== null) {
clearInterval(t);
}
t = setTimeout(() => {
fn.call(this);
}, delay);
};
}
边栏推荐
- WinCC7.5 SP1调整画面尺寸以适应显示分辨率的方法
- vc hacon 联合编程 GenImage3Extern WriteImage
- Fault analysis | a case of MySQL remote slave database replication delay
- 从16页PPT里看懂Jack Dorsey的Web5
- Add, delete, modify and query mysql, common MySQL commands
- synchronized下的 i+=2 和 i++ i++执行结果居然不一样
- Ctfshow-web265 (deserialization)
- [image denoising] image denoising based on regularization with matlab code
- const
- QT -- how to get the contents of selected cells in qtableview
猜你喜欢

什么是数据驱动

leetcodeSQL:578. Questions with the highest response rate

Implementation of exec function and shell

用户权限和组权限

基于微信电子书阅读小程序毕业设计毕设作品(7)中期检查报告

Business opportunities with an annual increase of 3billion - non cage eggs or a new blue ocean for export to ASEAN

Understand Jack Dorsey's web5 from the ppt on page 16

基于微信电子书阅读小程序毕业设计毕设作品(4)开题报告

Shell 数组和函数

进程会计、进程时间、守护进程
随机推荐
JDBC接口总结
什么是数据驱动
vc hacon 联合编程 GenImage3Extern WriteImage
leetcodeSQL:602. Friend application II: who has the most friends
Wechat e-book reading applet graduation design work (6) opening defense ppt
What are the third-party software testing organizations in Shanghai that share knowledge about software validation testing?
Original introduction to Jenkins' configuration options
EFCore调优
Analysis report on market demand and investment strategy of China's re guarantee industry 2022-2028
QT -- how to get the contents of selected cells in qtableview
Reading small program based on wechat e-book graduation design (4) opening report
2022年最新宁夏建筑安全员模拟题库及答案
Original publishing practice of pipeline in Jenkins docking with CMDB interface to obtain host list
synchronized下的 i+=2 和 i++ i++执行结果居然不一样
Process creation fork (), demise wait()
mysql的增删改查,mysql常用命令
RT thread simulator builds lvgl development and debugging environment
How does Eldon's ring of the law get lune quickly? Introduction to the fastest and safest method for obtaining lune
IO流基础知识详解--文件及IO流原理
腾讯云TDP-virt-viewer win客户端的软件使用