Skip to content

armgit / pdfcn

Public Imported from GitHub
0

Beautiful pdf components, built on Takumi and Forme. 100% Free, Zero config, one command setup.

516 B
Raw Blame
import { useCallback, useRef } from "react";

export interface AnimatedIconHandle {
  startAnimation: () => void;
  stopAnimation: () => void;
}

export const useIconAnimation = <
  T extends AnimatedIconHandle = AnimatedIconHandle,
>() => {
  const iconRef = useRef<T>(null);

  const onMouseEnter = useCallback(() => {
    iconRef.current?.startAnimation();
  }, []);

  const onMouseLeave = useCallback(() => {
    iconRef.current?.stopAnimation();
  }, []);

  return { iconRef, onMouseEnter, onMouseLeave };
};