当前位置:网站首页>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)
}
}
边栏推荐
- What is the difference between port number and process number?
- Int and bit group turn to each other
- @ConfigurationProperties和@Value的区别
- Sitge joined the opengauss open source community to jointly promote the ecological development of the database industry
- C#生成putty格式的ppk文件(支持passphrase)
- 522. 最长的特殊序列 II
- RocketQA:通过跨批次负采样(cross-batch negatives)、去噪的强负例采样(denoised hard negative sampling)与数据增强(data augment
- PMP是什么?
- Electron pit Addon
- ANR问题的分析与解决思路
猜你喜欢

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

LabVIEW calculates the camera image sensor resolution and lens focal length
![[fundamentals of wireless communication-14]: illustrated mobile communication technology and application development-2-the first generation mobile analog communication big brother](/img/fa/f9bad44147ba9af21183b7bd630e32.png)
[fundamentals of wireless communication-14]: illustrated mobile communication technology and application development-2-the first generation mobile analog communication big brother

Int and bit group turn to each other

Fix names in the table (first character uppercase, other lowercase)

(翻译)实时内联验证更容易让用户犯错的原因

AS400 API 从零到一的整个历程

@The difference between configurationproperties and @value

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

Machine learning 10 belief Bayesian classifier
随机推荐
7-2 punch in reward DP for puzzle a
522. Longest special sequence II
Objects and object variables
SWT / anr problem - storagemanagerservice stuck
What is project management?
【毕业季·进击的技术er】--毕业到工作小结
Pytorch - - Basic Reference North Deux élèves du secondaire peuvent comprendre [Rétropropagation et Gradient descendant]
SWT / anr problem - SWT caused by long execution time of native method
The mobile edge browser cannot open the third-party application
CorelDRAW 2022 Chinese Simplified 64 bit direct download
[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
What is the difference between port number and process number?
P6773 [NOI2020] 命运(dp、线段树合并)
SWT/ANR问题--Dump时间过长导致的SWT
House change for agricultural products? "Disguised" house purchase subsidy!
现在开户有优惠吗?另外,手机开户安全么?
What are the top ten securities companies? In addition, is it safe to open an account online now?
Is there any discount for opening an account now? In addition, is it safe to open a mobile account?
AS400 大廠面試
Upstream and downstream in software development