Home
import Lottie, { LottieRef } from 'solid-lottie';
const App: VoidComponent = () => {
let lottieRef: LottieRef | undefined;
const handleDataReady = () => {
if (!lottieRef) return;
lottieRef.play();
};
return (
<>
<Lottie path="/animation.json" loop ref={(v) => (ref = v)} onDataReady={() => handleDataReady()} />
</>
);
};
All of the props are optional but you must provide path
or animationData
or the component will throw an exception!
A JSON object with exported animation data (you must provide path
or animationData
)
A path to a json file with exported animation data (you must provide path
or animationData
)
Takes in a function which as an arguments takes an object containing all of the interaction methods
(The way this is done is weird, or at least I think, there might be another way to get the interaction methods to the parent?)
If set to true animation will start playing automatically
If set to true animation will loop infinitely
Name of the animation
An array with two numerical items (frames). If set the frames will define the first and the last frame of animation playback
Defaults to 100%
, it's the width of the container, if style
objects contains width
it will be used instead.
Defaults to 100%
, it's the height of the container, if style
objects contains height
it will be used instead.
Object containing CSS properties for the container
Event fired when the animation has completed playing
Event fired when the animation has completed playing a loop
Event fired when the animation playback has entered a frame
Event fired when the animation playback started playing a segment
Event fired when the config is ready
Event fired when the animation data has been loaded and are ready to be used
Event fired when an error has occurred while loading the animation data
Event fired when external images have been loaded (Not sure about this one)
Event fire when the DOM of the animation has been loaded
Event fired when the animation has been destroyed
Event fired when an error has occurred
Methods used for interaction with the animation.
Destroy the animation
destroys the animation
Stops the animation playback and goes to the first frame
Starts the animation playback from the current frame
Stops the animation playback and stays on the last played frame
Takes in a value and and optional second argument. Goes to the set value and if the second argument is true then the value is considered a frame number, resumes the playback.
Takes in a value and and optional second argument. Goes to the set value and if the second argument is true then the value is considered a frame number, stops the playback.
Takes in a value and and optional second argument. Returns the duration of the animation and if the second argument is true then the value is considered a frame number
Sets the speed of the animation playback, defaults to 1
Sets the direction of the animation playback, -1 is reverse, 1 is forward
Takes in a segment or an array of segments, second optional argument if set to true forces to resume the playback from the set segment instead of waiting for the currently playing segment to finish.
If set to true it will ignore the exported AE framerate and update on every requestAnimationFrame