@yesstudio/yes-utils
    Preparing search index...

    Function throttle

    • Creates a throttled function that only invokes func at most once per every animation frame using requestAnimationFrame. The func will be invoked with the context and arguments of the throttled function.

      Type Parameters

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

      Parameters

      • func: T

        The function to throttle.

      Returns (...args: Parameters<T>) => void

      Returns the new throttled function.

      This function is intended for use in environments where requestAnimationFrame is available. It does not contain a polyfill for server-side environments.

      // Avoid costly calculations while the window size is in flux.
      window.addEventListener.on('resize', throttle(calculateLayout))