Count: 1

useRafFn

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

Usage

import { ref } from 'vue'
import { useRafFn } from '@vueuse/core'

const count = ref(0)

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

Type Declarations

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

Source

SourceDemoDocs