react-lottie-hook
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -29,2 +29,8 @@ /// <reference types="react" /> | ||
} | ||
interface UseLottieState { | ||
isStopped: boolean; | ||
isPaused: boolean; | ||
isLoaded: boolean; | ||
playDirection: number; | ||
} | ||
interface AnimationDispatch { | ||
@@ -36,4 +42,4 @@ play(): void; | ||
selectAnimation: (newAnimation: AnimationConfigWithPath | AnimationConfigWithData) => void; | ||
setDirection(direction: AnimationDirection): void; | ||
setSpeed?(speed?: number): void; | ||
setDirection?(direction: AnimationDirection): void; | ||
resize?(): void; | ||
@@ -84,2 +90,3 @@ goToAndPlay?(value: number, isFrame?: boolean): void; | ||
isLoaded: boolean; | ||
playDirection: AnimationDirection; | ||
} | ||
@@ -124,10 +131,6 @@ type BMEventType<T = string> = { | ||
React.MutableRefObject<HTMLDivElement | null>, | ||
{ | ||
isStopped: boolean; | ||
isPaused: boolean; | ||
isLoaded: boolean; | ||
}, | ||
UseLottieState, | ||
AnimationDispatch | ||
]; | ||
declare const ClickAway: React.ForwardRefExoticComponent<ClickAwayProps & React.RefAttributes<unknown>>; | ||
export { Lottie, useLottie, ClickAway, LottieProps, ClickAwayProps, LottieAnimationItem, AnimationDispatch, LottieOptions, Renderer, AnimationData, LottieConfig, EventListener, LottieState, BMCompleteEvent, BMCompleteLoopEvent, BMEnterFrameEvent, BMDestroyEvent, BMSegmentStartEvent, BMRenderFrameErrorEvent, BMConfigErrorEvent, BMAnimationConfigErrorEvent, AnimationEventTypes }; | ||
export { Lottie, useLottie, ClickAway, LottieProps, ClickAwayProps, LottieAnimationItem, UseLottieState, AnimationDispatch, LottieOptions, Renderer, AnimationData, LottieConfig, EventListener, LottieState, BMCompleteEvent, BMCompleteLoopEvent, BMEnterFrameEvent, BMDestroyEvent, BMSegmentStartEvent, BMRenderFrameErrorEvent, BMConfigErrorEvent, BMAnimationConfigErrorEvent, AnimationEventTypes }; |
@@ -49,3 +49,4 @@ 'use strict'; | ||
isPaused: false, | ||
isLoaded: false | ||
isLoaded: false, | ||
playDirection: 1 | ||
}), state = _l[0], dispatch = _l[1]; | ||
@@ -119,2 +120,9 @@ var hasOwnProperty = React.useCallback(function (anim, prop) { return object.isPopulated(anim) && !!anim[prop]; }, []); | ||
}, [animation, hasOwnProperty]); | ||
var setDirection = React.useCallback(function (direction) { | ||
if (direction === void 0) { direction = 1; } | ||
if (hasOwnProperty(animation, "setDirection")) { | ||
animation === null || animation === void 0 ? void 0 : animation.setDirection(direction); | ||
update({ playDirection: direction }); | ||
} | ||
}, [animation, hasOwnProperty]); | ||
var selectAnimation = React.useCallback(function (newAnimation) { | ||
@@ -134,3 +142,4 @@ if (object.isPopulated(animation) && object.isPopulated(newAnimation)) { | ||
destroy: destroy, | ||
selectAnimation: selectAnimation })); }, [animation, play, playSegments, stop, pause, destroy, selectAnimation]); | ||
setDirection: setDirection, | ||
selectAnimation: selectAnimation })); }, [animation, play, playSegments, stop, pause, destroy, setDirection, selectAnimation]); | ||
React.useEffect(function () { | ||
@@ -178,3 +187,3 @@ var anim = lottie__default['default'].loadAnimation(animationConfig(lottieRef.current)); | ||
]); | ||
var isStopped = state.isStopped, isPaused = state.isPaused, isLoaded = state.isLoaded; | ||
var isStopped = state.isStopped, isPaused = state.isPaused, isLoaded = state.isLoaded, playDirection = state.playDirection; | ||
return [ | ||
@@ -185,3 +194,4 @@ lottieRef, | ||
isPaused: isPaused, | ||
isLoaded: isLoaded | ||
isLoaded: isLoaded, | ||
playDirection: playDirection | ||
}, | ||
@@ -188,0 +198,0 @@ controls, |
@@ -29,2 +29,8 @@ /// <reference types="react" /> | ||
} | ||
interface UseLottieState { | ||
isStopped: boolean; | ||
isPaused: boolean; | ||
isLoaded: boolean; | ||
playDirection: number; | ||
} | ||
interface AnimationDispatch { | ||
@@ -36,4 +42,4 @@ play(): void; | ||
selectAnimation: (newAnimation: AnimationConfigWithPath | AnimationConfigWithData) => void; | ||
setDirection(direction: AnimationDirection): void; | ||
setSpeed?(speed?: number): void; | ||
setDirection?(direction: AnimationDirection): void; | ||
resize?(): void; | ||
@@ -84,2 +90,3 @@ goToAndPlay?(value: number, isFrame?: boolean): void; | ||
isLoaded: boolean; | ||
playDirection: AnimationDirection; | ||
} | ||
@@ -124,10 +131,6 @@ type BMEventType<T = string> = { | ||
React.MutableRefObject<HTMLDivElement | null>, | ||
{ | ||
isStopped: boolean; | ||
isPaused: boolean; | ||
isLoaded: boolean; | ||
}, | ||
UseLottieState, | ||
AnimationDispatch | ||
]; | ||
declare const ClickAway: React.ForwardRefExoticComponent<ClickAwayProps & React.RefAttributes<unknown>>; | ||
export { Lottie, useLottie, ClickAway, LottieProps, ClickAwayProps, LottieAnimationItem, AnimationDispatch, LottieOptions, Renderer, AnimationData, LottieConfig, EventListener, LottieState, BMCompleteEvent, BMCompleteLoopEvent, BMEnterFrameEvent, BMDestroyEvent, BMSegmentStartEvent, BMRenderFrameErrorEvent, BMConfigErrorEvent, BMAnimationConfigErrorEvent, AnimationEventTypes }; | ||
export { Lottie, useLottie, ClickAway, LottieProps, ClickAwayProps, LottieAnimationItem, UseLottieState, AnimationDispatch, LottieOptions, Renderer, AnimationData, LottieConfig, EventListener, LottieState, BMCompleteEvent, BMCompleteLoopEvent, BMEnterFrameEvent, BMDestroyEvent, BMSegmentStartEvent, BMRenderFrameErrorEvent, BMConfigErrorEvent, BMAnimationConfigErrorEvent, AnimationEventTypes }; |
@@ -40,3 +40,4 @@ import { __assign } from 'tslib'; | ||
isPaused: false, | ||
isLoaded: false | ||
isLoaded: false, | ||
playDirection: 1 | ||
}), state = _l[0], dispatch = _l[1]; | ||
@@ -110,2 +111,9 @@ var hasOwnProperty = useCallback(function (anim, prop) { return object.isPopulated(anim) && !!anim[prop]; }, []); | ||
}, [animation, hasOwnProperty]); | ||
var setDirection = useCallback(function (direction) { | ||
if (direction === void 0) { direction = 1; } | ||
if (hasOwnProperty(animation, "setDirection")) { | ||
animation === null || animation === void 0 ? void 0 : animation.setDirection(direction); | ||
update({ playDirection: direction }); | ||
} | ||
}, [animation, hasOwnProperty]); | ||
var selectAnimation = useCallback(function (newAnimation) { | ||
@@ -125,3 +133,4 @@ if (object.isPopulated(animation) && object.isPopulated(newAnimation)) { | ||
destroy: destroy, | ||
selectAnimation: selectAnimation })); }, [animation, play, playSegments, stop, pause, destroy, selectAnimation]); | ||
setDirection: setDirection, | ||
selectAnimation: selectAnimation })); }, [animation, play, playSegments, stop, pause, destroy, setDirection, selectAnimation]); | ||
useEffect(function () { | ||
@@ -169,3 +178,3 @@ var anim = lottie.loadAnimation(animationConfig(lottieRef.current)); | ||
]); | ||
var isStopped = state.isStopped, isPaused = state.isPaused, isLoaded = state.isLoaded; | ||
var isStopped = state.isStopped, isPaused = state.isPaused, isLoaded = state.isLoaded, playDirection = state.playDirection; | ||
return [ | ||
@@ -176,3 +185,4 @@ lottieRef, | ||
isPaused: isPaused, | ||
isLoaded: isLoaded | ||
isLoaded: isLoaded, | ||
playDirection: playDirection | ||
}, | ||
@@ -179,0 +189,0 @@ controls, |
{ | ||
"name": "react-lottie-hook", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"license": "MIT", | ||
@@ -34,2 +34,5 @@ "description": "React Lottie written with react hooks", | ||
], | ||
"contributors": [ | ||
"Arno (H) Welgemoed <arno.welgemoed@outlook.com> (ahwelgemoed.dev)" | ||
], | ||
"peerDependencies": { | ||
@@ -36,0 +39,0 @@ "react": ">= 16.8.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
102921
9
853
1
92