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
}
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 /useRafFn
* @param fn
* @param options
*/
export declare function useRafFn(fn: Fn, options?: RafFnOptions): RafFnReturn