import { useAnimationTimer } from './useAnimationTimer' ; import { linear , elastic , inExpo } from '~/services/easing' ; export enum Easing { Linear = 'linear' , Elastic = 'elastic' , InExpo = 'inExpo' } export function useAnimation ( easing = Easing . Linear , duration = 500 , delay = 0 ) { const elapsed = useAnimationTimer ( duration , delay ) ; const n = Math . min ( 1 , elapsed / duration ) ; switch ( easing ) { case Easing . Linear : return linear ( n ) ; case Easing . Elastic : return elastic ( n ) ; case Easing . InExpo : return inExpo ( n ) ; } }