Skip to content

useRafFn

Package
Share - Core
Category
Description
call function on every `requestAnimationFrame`

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

Demo

Frames: 0
Delta: 0ms
FPS Limit: 60

Usage

js
import { ref } from 'vue';
import { useRafFn } from '@hungpvq/shared-core';

const count = ref(0);

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