DotLottie

The DotLottie class is the main entry point for creating dotLotties. Manage animations, export type, plugins and more.

DotLottieOptions

interface DotLottieOptions {
  author?: string;
  customData?: Record<string, string>,
  description?: string;
  enableDuplicateImageOptimization?: boolean;
  generator?: string;
  keywords?: string;
  plugins?: DotLottiePlugin[];
  version?: string;
}

Options

author?: string

Author of the DotLottie. Will be used inside of the manifest file.

Default value: 'LottieFiles'

customData?: Record<string, string>;

Any custom data the manifest should contain.

description?: string

Description of the DotLottie. Will be used inside of the manifest file.

enableDuplicateImageOptimization?: boolean

If set to true it will detect duplicate images across the animations inside of the dotLottie and reduce their usage to a single source.

Default value: false

generator?: string

Define the dotLottie generation tool. Will be used inside of the manifest file.

Default value: 'dotLottie-js_v[CURRENT_VERSION]'

keywords?: string

Keywords for the DotLottie. Will be used inside of the manifest file.

Default value: 'dotLottie'

plugins?: DotLottiePlugin[]

An array of plugins that will be ran after a call to DotLottie.build(). For more information on plugins and how to create them, check out the plugins page.

version?: string

Version of the animation. Will be used in side of the manifest file.

Default value: '1.0'

Methods

setCustomData(customData: Record<string, unknown>): DotLottieCommon 
setDescription(description: string): DotLottieCommon
setGenerator(generator: string): DotLottieCommon
setKeywords(keywords: string): DotLottieCommon
setVersion(version: string): DotLottieCommon

addAnimation(animationOptions: AnimationOptions): Dotlottie

View the AnimationOptions.

getImages(): LottieImageCommon[]

Returns an Array of LottieImageCommon from every LottieAnimation contained within the DotLottie.

addPlugins(...plugins: DotLottiePlugin[]): DotLottieCommon

Add a or multiple plugins. Plugins are ran after calling DotLottie.build(). For more information on plugins check out the plugins page.

removePlugins(...plugins: DotLottiePlugin[]): DotLottieCommon

Remove a single or multiple plugins.

removeAnimation(animationId: string): DotLottieCommon

getAnimation(animationId: string, {inlineAssets?: boolean}): LottieAnimationCommon | undefined

Returns the requested animation, assets can be optionally inlined inside the data of the animation.

getAnimations(): Array<[string, LottieAnimationCommon]> | undefined

Returns an array of tuples containing the LottieAnimation id, and the LottieAnimation object.

---------------------------------------------------------------------------------------------------

Export and utility methods

async toArrayBuffer(): Promise<ArrayBuffer>

Builds the manifest and exports the dotLottie as an ArrayBuffer.

async toBlob(): Promise

Builds the manifest and exports the dotLottie as a Blob.

async toBase64(): Promise<string>

Builds the manifest and exports the dotLottie as a Base64 encoded string.

async build(): Promise<DotLottieCommon>

Animations will only be fetched when build() is called!

Builds the manifest and fetches the animations from their URLs if they were added with one. Also runs the plugins on the DotLottie context.

async download(fileName: string): Promise<void>

For browsers only.

Builds the DotLottie and downloads the .lottie file. If user is on a node environment, this method will throw an error.

static async fromURL(url: string): Promise<DotLottieCommon>

Creates and returns a DotLottie object created from the .lottie file residing at the supplied URL.

static async fromArrayBuffer(arrayBuffer: ArrayBuffer): Promise<DotLottieCommon>

Creates and returns a DotLottie object created from the supplied ArrayBuffer of a DotLottie.

static merge(...dotlotties: DotLottieCommon[]): DotLottieCommon

Merges the provided DotLotties in to a single DotLottie and returns it.

Last updated