Configuration and Usage
Explains how to configure and use the Lottie-Interactivity library to create interactive animations.
The following code snippet demonstrates a sample configuration:
The name of the player - firstLottie in the sample configuration is the ID of the lottie-player web component that you use on the HTML page. For example:
The configuration includes an actions array. This array defines the actions mode for one or multiple objects.
You can add multiple objects to this array and set actions such as seek, play, stop and loop to animate them.
The configuration for each object has a start and end value between 0 and 1. This value is a percentage for the height of the Lottie container, where 0 indicates 0% and 1 indicates 100%.
The visibility arrays contain these start and end values. For example:
Ensure that the ending frame is where you want the interactivity to end. This frame could be the last frame or a frame of your choosing.
The configuration can include a container field. If you do not specify a container for the action, the library selects the parent div as the container.
Configuration for React
The configuration for the library remains the same for react apps. However usage and initialization is as follows. Import the create function from the Lottie-Interactivity library and call the create function. With frameworks like React it is ideal to add an event listener that waits for the Lottie player to load before calling the interactivity library. An example is as follows for a very basic react class component.
Configuration for Vue
The configuration for the library remains the same for Vue apps. However usage and initialization is as follows. Import the create function from the Lottie-Interactivity library and call the create function. With frameworks like Vue it is ideal to add an event listener that waits for the Lottie player to load before calling the interactivity library. An example is as follows for a very basic Vue class component.
Last updated