@jurneyx2/react-lottie-hooks
Version:
🎯 Simple and powerful React hooks for DotLottie animations with GSAP ScrollTrigger integration and automatic SSR/CSR detection
57 lines (54 loc) • 1.91 kB
text/typescript
import React from 'react';
import { DotLottie } from '@lottiefiles/dotlottie-react';
interface UseLottieScrollTriggerOptions {
start?: string;
end?: string;
markers?: boolean;
pauseOnLoad?: boolean;
debug?: boolean;
debugLanguage?: "ko" | "en";
strictMode?: boolean;
waitForDOMReady?: boolean;
enableStateTracking?: boolean;
frameUpdateThrottle?: number;
onPlayStateChange?: (isPlaying: boolean) => void;
onFrameChange?: (currentFrame: number) => void;
onEnter?: (dotLottie: DotLottie) => void;
onLeave?: (dotLottie: DotLottie) => void;
onEnterBack?: (dotLottie: DotLottie) => void;
onLeaveBack?: (dotLottie: DotLottie) => void;
gsapAnimations?: {
rotation?: number;
scale?: number;
x?: number;
y?: number;
opacity?: number;
duration?: number;
ease?: string;
trigger?: "enter" | "enterBack" | "leave" | "leaveBack" | "scroll";
scrub?: boolean | number;
};
scrollTriggerOptions?: Partial<ScrollTrigger.StaticVars>;
}
interface UseLottieScrollTriggerReturn {
triggerRef: React.RefObject<HTMLDivElement>;
lottieContainerRef: React.RefObject<HTMLDivElement>;
isMounted: boolean;
isDOMReady: boolean;
isClient: boolean;
isLoaded: boolean;
handleDotLottieRef: (dotLottie: DotLottie | null) => void;
dotLottie: DotLottie | null;
isDotLottieLoaded: boolean;
play: () => void;
pause: () => void;
stop: () => void;
setFrame: (frame: number) => void;
getCurrentFrame: () => number;
getIsPlaying: () => boolean;
isPlaying: boolean;
currentFrame: number;
isSSRFramework: boolean;
}
declare const useLottieScrollTrigger: (options?: UseLottieScrollTriggerOptions) => UseLottieScrollTriggerReturn;
export { type UseLottieScrollTriggerOptions, type UseLottieScrollTriggerReturn, useLottieScrollTrigger };