DotLottie
DotLottieOptions
interface DotLottieOptions { author?: string; customData?: Record<string, string>, description?: string; enableDuplicateImageOptimization?: boolean; generator?: string; keywords?: string; plugins?: DotLottiePlugin[]; version?: string;}Options
author?: stringAuthor 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?: stringDescription of the DotLottie. Will be used inside of the manifest file.
enableDuplicateImageOptimization?: booleanIf 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?: stringDefine the dotLottie generation tool. Will be used inside of the manifest file.
Default value: 'dotLottie-js_v[CURRENT_VERSION]'
keywords?: stringKeywords 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?: stringVersion of the animation. Will be used in side of the manifest file.
Default value: '1.0'
Methods
setCustomData(customData: Record<string, unknown>): DotLottieCommonsetDescription(description: string): DotLottieCommonsetGenerator(generator: string): DotLottieCommonsetKeywords(keywords: string): DotLottieCommonsetVersion(version: string): DotLottieCommonaddAnimation(animationOptions: AnimationOptions): DotlottieView the AnimationOptions.
getImages(): LottieImageCommon[]Returns an Array of LottieImageCommon from every LottieAnimation contained within the DotLottie.
addPlugins(...plugins: DotLottiePlugin[]): DotLottieCommonAdd a or multiple plugins. Plugins are ran after calling DotLottie.build(). For more information on plugins check out the plugins page.
removePlugins(...plugins: DotLottiePlugin[]): DotLottieCommonRemove a single or multiple plugins.
removeAnimation(animationId: string): DotLottieCommongetAnimation(animationId: string, {inlineAssets?: boolean}): LottieAnimationCommon | undefinedReturns the requested animation, assets can be optionally inlined inside the data of the animation.
getAnimations(): Array<[string, LottieAnimationCommon]> | undefinedReturns 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(): PromiseBuilds 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[]): DotLottieCommonMerges the provided DotLotties in to a single DotLottie and returns it.