Count: 1

useRafFn

Call function on every requestAnimationFrame. With controls of pausing and resuming.

Usage

import { useRafFn } from '@vueuse/core'

const { pause, resume } = useRafFn((elapsed) => {
  console.log(elapsed.value)
})

Type Declarations

export interface RafFnOptions extends ConfigurableWindow {
  /**
   * Start the requestAnimationFrame loop immediately on creation
   *
   * @default true
   */
  immediate?: boolean
}
export interface RafFnReturn extends Pausable {
  /**
   * @deprecated use pause() instead
   */
  stop: Fn
  /**
   * @deprecated use resume() instead
   */
  start: Fn
}
/**
 * Call function on every `requestAnimationFrame`. With controls of pausing and resuming.
 *
 * @see   {@link /useRafFn}
 * @param fn
 * @param options
 */
export declare function useRafFn(fn: Fn, options?: RafFnOptions): RafFnReturn

Source

SourceDemoDocs