当前位置:网站首页>《看完就懂系列》天哪!搞懂节流与防抖竟简单如斯~
《看完就懂系列》天哪!搞懂节流与防抖竟简单如斯~
2022-07-07 10:07:00 【InfoQ】
写在前面
防抖篇
*防抖小故事
*防抖逻辑图
*防抖代码实现
setTimeout
setTimeout
setTimeout
setTimeout
setTimeout
setTimeout
// 防抖初始变量
let debouncTtimeout
// 点击防抖按钮触发函数
function debounce() {
clearTimeout(debouncTtimeout)
debouncTtimeout = setTimeout(function () {
console.log("执行防抖操作啦~")
}, 3000)
}
节流篇
*节流小故事
*节流逻辑图
*节流代码实现
// 节流初始时间戳
let pastDate = new Date().valueOf()
// 点击节流按钮触发函数
function throttle() {
let nowDate = new Date().valueOf()
if (nowDate - pastDate > 3000) {
console.log('执行节流操作啦~')
pastDate = new Date().valueOf()
}
}
总结
写在后面
边栏推荐
- Unity中SmoothStep介绍和应用: 溶解特效优化
- Internet Protocol
- Camera calibration (1): basic principles of monocular camera calibration and Zhang Zhengyou calibration
- Cmu15445 (fall 2019) project 2 - hash table details
- How much do you know about excel formula?
- Poor math students who once dropped out of school won the fields award this year
- Swiftui tutorial how to realize automatic scrolling function in 2 seconds
- . Net Maui performance improvement
- STM32F1与STM32CubeIDE编程实例-MAX7219驱动8位7段数码管(基于SPI)
- Unity 贴图自动匹配材质工具 贴图自动添加到材质球工具 材质球匹配贴图工具 Substance Painter制作的贴图自动匹配材质球工具
猜你喜欢
NPC Jincang was invited to participate in the "aerospace 706" I have an appointment with aerospace computer "national Partner Conference
Programming examples of stm32f1 and stm32subeide -315m super regenerative wireless remote control module drive
【滤波跟踪】基于matlab捷联惯导仿真【含Matlab源码 1935期】
正在运行的Kubernetes集群想要调整Pod的网段地址
How to write test cases for test coupons?
Talk about SOC startup (VI) uboot startup process II
SwiftUI 4 新功能之掌握 WeatherKit 和 Swift Charts
总结了200道经典的机器学习面试题(附参考答案)
【数据聚类】基于多元宇宙优化DBSCAN实现数据聚类分析附matlab代码
5V串口接3.3V单片机串口怎么搞?
随机推荐
Programming examples of stm32f1 and stm32subeide -315m super regenerative wireless remote control module drive
Up meta - Web3.0 world innovative meta universe financial agreement
Visual Studio 2019 (LocalDB)\MSSQLLocalDB SQL Server 2014 数据库版本为852无法打开,此服务器支持782版及更低版本
Detailed explanation of debezium architecture of debezium synchronization
千人规模互联网公司研发效能成功之路
【紋理特征提取】基於matlab局部二值模式LBP圖像紋理特征提取【含Matlab源碼 1931期】
Fleet tutorial 19 introduction to verticaldivider separator component Foundation (tutorial includes source code)
《通信软件开发与应用》课程结业报告
SwiftUI Swift 内功之 Swift 中使用不透明类型的 5 个技巧
Blog moved to Zhihu
How much do you know about excel formula?
Flet教程之 18 Divider 分隔符组件 基础入门(教程含源码)
大佬们有没有人遇到过 flink oracle cdc,读取一个没有更新操作的表,隔十几秒就重复读取
[shortest circuit] acwing 1127 Sweet butter (heap optimized dijsktra or SPFA)
When sink is consumed in mysql, the self incrementing primary key has been set in the database table. How to operate in Flink?
正在運行的Kubernetes集群想要調整Pod的網段地址
清华姚班程序员,网上征婚被骂?
Enclosed please find. Net Maui's latest learning resources
Common locking table processing methods in Oracle
【神经网络】卷积神经网络CNN【含Matlab源码 1932期】