use-animate-style.mjs 600 B

1234567891011121314151617
  1. import { useConstant } from '../../utils/use-constant.mjs';
  2. import { useUnmountEffect } from '../../utils/use-unmount-effect.mjs';
  3. import { createScopedWaapiAnimate } from '../animators/waapi/animate-style.mjs';
  4. function useAnimateMini() {
  5. const scope = useConstant(() => ({
  6. current: null, // Will be hydrated by React
  7. animations: [],
  8. }));
  9. const animate = useConstant(() => createScopedWaapiAnimate(scope));
  10. useUnmountEffect(() => {
  11. scope.animations.forEach((animation) => animation.stop());
  12. });
  13. return [scope, animate];
  14. }
  15. export { useAnimateMini };