@pengzhanbo/utils - v3.4.1
    Preparing search index...

    Function throttle

    • Throttle execution of a function. Especially useful for rate limiting execution of handlers on events like resize and scroll.

      限制函数的执行频率。特别适用于限制事件处理程序的执行速率,例如调整大小和滚动事件。

      Type Parameters

      • T extends (...args: any[]) => any

      Parameters

      • delay: number

        A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful. 一个零或更大的延迟时间,以毫秒为单位。对于事件回调,大约100或250(甚至更高)的值最为实用。

      • callback: T

        A function to be executed after delay milliseconds. The this context and all arguments are passed through, as-is, to callback when the throttled-function is executed. 一个在延迟毫秒后执行的函数。当节流函数执行时,this上下文和所有参数都会原样传递给callback

      • Optionaloptions: ThrottleOptions

        An object to configure options. 用于配置选项的对象。

      Returns FnNoReturn<T> & Cancel

      A new throttled function. 新的节流函数