react-textmotion
Version:
Lightweight yet powerful library that provides variable animation effects for React applications.
28 lines (27 loc) • 1.5 kB
TypeScript
import { type ReactNode } from 'react';
import type { AnimationOrder, Motion } from '../../types';
type UseAnimatedChildrenProps = {
splittedNode: ReactNode[];
initialDelay: number;
animationOrder: AnimationOrder;
resolvedMotion: Motion;
onAnimationEnd?: () => void;
};
/**
* @description
* `useAnimatedChildren` is a custom hook that animates an array of React nodes.
* It manages the animation sequence index to apply delays correctly.
*
* @param {ReactNode[]} splittedNode - The array of React nodes to be animated.
* @param {number} initialDelay - The initial delay before the animation starts, in seconds.
* @param {AnimationOrder} animationOrder - Defines the order in which the animation sequence is applied. Defaults to `'first-to-last'`.
* @param {Motion} resolvedMotion - The motion configuration object, which is a result of merging custom motion and presets.
* @param {() => void} onAnimationEnd - Callback function that is called when the animation ends.
*
* @returns {ReactNode[]} An array of animated React nodes.
*/
export declare const useAnimatedChildren: ({ splittedNode, initialDelay, animationOrder, resolvedMotion, onAnimationEnd, }: UseAnimatedChildrenProps) => ReactNode[];
export declare const wrapWithAnimatedSpan: (splittedNode: ReactNode[], initialDelay: number, animationOrder: AnimationOrder, resolvedMotion: Motion, totalNodes: number, sequenceIndexRef: {
current: number;
}, onAnimationEnd?: () => void) => ReactNode[];
export {};