Git Product home page Git Product logo

lottie-js's Introduction

lottie-js

An object model for representing the Lottie JSON structure.

This library was created to make interacting with the Lottie JSON object simpler. The library consists of methods to map the Lottie JSON to the object model and interact with properties as well as manipulate them. The goal is to fully map the Lottie object model and add in enough helper methods to the library such that Lottie manipulation can be made easier without having to learn the entire complex structure of a Lottie file.

Full Documentation is available here Click me

Usage

  1. Install
yarn add @lottiefiles/[email protected]
  1. Use
import { Animation } from '@lottiefiles/lottie-js';

async function loadAnimation() {
  // Create Lottie instance
  // (you can also use Animation.fromJSON method if you already have the Lottie JSON loaded)
  const anim = await Animation.fromURL('https://assets1.lottiefiles.com/packages/lf20_u4j3xm6r.json');

  // Print some data of the animation
  console.log('Frame Rate', anim.frameRate);
  console.log('Number of Layers', anim.layers.length);
  console.log(anim.getColors());

  // Manipulate animation
  anim.name = 'Woohoo';
  anim.width = 512;
  anim.height = 512;

  // Get the new JSON
  const woohooLottie = JSON.stringify(anim);
  console.log(woohooLottie);
}

Promise.resolve(loadAnimation());

Documentation & API


The documenting system used is TypeDoc.

Clone the repo and run the yarn command: yarn docs to generate the docs to browse locally.

The generated documentation is placed in the docs/ folder.

Testing


The testing system used is Jest and each file should have an accompanying test suite for functional and integration tests.

Development


Development work on the toolkit requires Nodejs and Yarn.

Guidelines

  • Use defensive programming techniques: Ensure type and range of input values, cast values to native representation whenever possible, etc.
  • Refrain from using external dependencies: Discuss before adding a dependency. Check with Bundlephobia for package size and dependencies when choosing one.
  • Use code formatting in the IDE using the given eslint+prettier configs.
  • Write tests to cover all functions and code branches with valid and invalid values.

Setting up

git clone https://github.com/LottieFiles/lottie-js

cd lottie-js

yarn install

Running test suite

yarn test

Building

yarn build

lottie-js's People

Contributors

anilsonix avatar beve avatar flupke avatar jawish avatar karamalie avatar lottiefiles-bot avatar mbasaglia avatar thoaif avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.