当前位置:网站首页>js防抖和节流
js防抖和节流
2022-07-01 02:19:00 【kilito_01】
/ 节流函数
function throttle(callback, wait) {
let start = 0 ;
return function(e){
let now = Date.now()
if(now - start >= wait){
callback.call(this,e);
start = now;
}
}
}
// 防抖函数
function debounce(callback,time){
var timeout = null;
return function(e){
if(timeout != null){
clearTimeout(timeout)
}
//启动定时器
timeout = setTimeout(()=>{
callback.call(this,e)
timeout = null;
},time)
}
}
边栏推荐
- I want to know how to open a stock account? Is it safe to open an account online?
- What is PMP?
- How does the property send a text message to the owner?
- Laravel event & Monitoring
- Fast understanding of forward proxy and reverse proxy
- go导入自建包
- 522. 最长的特殊序列 II
- 7-2 punch in reward DP for puzzle a
- [Agora] user management
- Comment réaliser la liaison entre la serrure intelligente et la lampe, la scène du moteur de rideau intelligent dans le timing intelligent?
猜你喜欢
![[fundamentals of wireless communication-15]: illustrated mobile communication technology and application development-3-overview of digital communication 2G GSM, CDMA, 3G wdcma/cdma200/td-scdma, 4G LTE](/img/22/1efa444220131359b06005f597c9db.png)
[fundamentals of wireless communication-15]: illustrated mobile communication technology and application development-3-overview of digital communication 2G GSM, CDMA, 3G wdcma/cdma200/td-scdma, 4G LTE

Find the length of the common part of two line segments
The latest CSDN salary increase technology stack in 2022 overview of APP automated testing

Calculate special bonus
2022年最新csdn涨薪技术栈-app自动化测试概述

CentOS installs multiple versions of PHP and switches

Ernie-gram, 显式、完备的 n-gram 掩码语言模型,实现了显式的 n-gram 语义单元知识建模。

A preliminary understanding of operator overloading

Batch import of Excel data in applet

SWT/ANR问题--Binder Stuck
随机推荐
Sitge joined the opengauss open source community to jointly promote the ecological development of the database industry
SWT/ANR问题--StorageManagerService卡住
Short video platform development, relying on drawerlayout to achieve side sliding menu effect
@The difference between configurationproperties and @value
(translation) reasons why real-time inline verification is easier for users to make mistakes
PMP是什么?
There is no future to be expected. It is just the last fantasy of a migrant worker before he dies
【2022年】江西省研究生数学建模方案、代码
Winodws 快速添加开机启动项
SWT / anr problem - storagemanagerservice stuck
【JS】【掘金】获取关注了里不在关注者里的人
What other hot spots are hidden under 1500W playback? Station B 2 future trends you can't miss
Some uses of Halcon array
如何学习和阅读代码
LabVIEW calculates the camera image sensor resolution and lens focal length
The whole process of AS400 API from zero to one
[punch in questions] integrated daily 5 questions sharing (phase I)
删除重复的电子邮箱
Ernie-gram, 显式、完备的 n-gram 掩码语言模型,实现了显式的 n-gram 语义单元知识建模。
halcon变量窗口的图像变量不显示,重启软件和电脑都没用