New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@codeleap/lottie-editor

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codeleap/lottie-editor

Edit lottie files programatically

latest
Source
npmnpm
Version
1.0.6
Version published
Weekly downloads
6
-25%
Maintainers
3
Weekly downloads
 
Created
Source

Lottie Editor

Edit lottie files programmatically. Made with tinycolor2 and a lot of recursion.

Currently only supports editing colors.

Features

  • CLI for inspecting colors in lottie files
  • Typesafety
  • Supports tons of color formats
  • Edit animation colors in one line
  • Environment agnostic

Usage

Change colors

import fs from 'fs'
import { LottieAnimation } from '@codeleap/lottie-editor'

// This can be any lottie json
const json = JSON.parse(fs.readFileSync('./animation.json').toString())

const animation = new LottieAnimation(json)

const firstColorPath = Object.keys(animation.colors)[0] 

// Will output something like assets.0.layers.0.shapes.0.it.1.c.k. This is the path of a single color inside lottie's json
console.log(firstColorPath)

// This is a tinycolor object. All of it's methods (such as toRgbString()) are available.
console.log(animation.colors[firstColorPath]._color?.toRgbString())

// You can use any color like string supported by tinycolor2 in the place of #ff0000
animation.colors[firstColorPath].color = '#ff0000'

// This will set the colors in lottie's format inside animation.animationData
animation.saveColors()

// Additionally, now the lottie object includes metadata about it's colors. Useful for inspecting colors inside animations in vscode if you save the file
console.log('animationData.colors', animation.animationData?.colors)

// In react, you may simply pass animation.animationData to <Lottie /> and the colors will be correct

// When this file is rendered by lottie, it will have the colors you altered
fs.writeFileSync('./animation-red.json', JSON.stringify(animation.animationData), {
    encoding: 'utf-8'
})

FAQs

Package last updated on 22 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts