0
点赞
收藏
分享

微信扫一扫

throttle-debounce.js:一个小型的防抖节流函数库

Throttle and debounce functions.

文档:

  • ​​https://github.com/niksy/throttle-debounce​​
  • ​​https://www.npmjs.com/package/throttle-debounce​​
  • ​​https://www.jsdelivr.com/package/npm/throttle-debounce​​

Node.js

安装

npm install throttle-debounce --save

示例

import { throttle, debounce } from 'throttle-debounce';

// delay 100 or 250
throttle(delay, callback, { noLeading=false, noTrailing=false, debounceMode })

debounce(delay, callback, { atBegin=false })

CDN

<!-- 引入throttle-debounce -->
<script src="https://cdn.jsdelivr.net/npm/throttle-debounce@5.0.0/umd/index.min.js"></script>

<script>
const throttleFunc = throttleDebounce.throttle(1000, ()=>{});

const debounceFunc = throttleDebounce.debounce(1000, ()=>{});
</script>


举报

相关推荐

0 条评论