Animation

Animation contains all the information about the Lottie animation.

Hierarchy

  • Animation

Properties

assets

frameRate

frameRate: number = 0

height

height: number = 0

inPoint

inPoint: number = 0

The frame at which the Lottie animation starts at

is3D

is3D: boolean = false

layers

meta

meta: Meta = new Meta(this)

name

name: string = ""

outPoint

outPoint: number = 0

The frame at which the Lottie animation ends at

version

version: string = ``

width

width: number = 0

Accessors

colors

  • get colors(): string[]

  • Returns string[]

colorsVerbose

  • Returns array of colors with key representing the path of the color ie : frame, shape and layer the color exists in

duration

  • get duration(): number

  • Returns number

    Number of seconds.

fileSize

  • get fileSize(): number

  • Returns number

    Number of bytes.

totalFrames

  • get totalFrames(): number

  • Returns number

    Number of frames.

Methods

Static fromURL

  • fromURL(url: string): Promise<Animation>

  • Parameters

    • url: string

    Returns Promise<Animation>

    Animation instance

Create a class instance from the URL to the Lottie JSON.

createAsset

createAssetFromJSON

  • createAssetFromJSON(json: Record<string, any>): Asset

  • Parameters

    • json: Record<string, any>

    Returns Asset

createLayer

createLayerFromJSON

  • createLayerFromJSON(json: Record<string, any>): Layer

  • Parameters

    • json: Record<string, any>

    Returns Layer

fromJSON

  • fromJSON(json: Record<string, any>): Animation

  • Parameters

    • json: Record<string, any>

    Returns Animation

getLayerById

  • getLayerById(id: string): Layer | undefined

  • Parameters

    • id: string

    Returns Layer | undefined

    Layer instance.

getLayersByClassName

  • getLayersByClassName(className: string): Layer[]

  • Parameters

    • className: string

    Returns Layer[]

    Array of layer instances.

getLayersByType

  • getLayersByType(type: LayerType): Layer[]

  • Parameters

    • type: LayerType

    Returns Layer[]

    Layer instance.

toJSON

  • toJSON(key?: undefined | string): Record<string, any> | undefined

  • Parameters

    • Optional key: undefined | string

    Returns Record<string, any> | undefined

    JSON object

Static isLottie

  • isLottie(json: Record<string, any>): boolean

  • Parameters

    • json: Record<string, any>

    Returns boolean

    Boolean true if it is a valid Lottie

Returns whether the given object looks like a valid Lottie JSON structure.

This method checks for the presense of the mandatory fields 'v', 'ip', 'op', 'layers', 'fr', 'w' and 'h' in the object.

Last updated