Giter Site home page Giter Site logo

grifotv / lottie-react-native Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lottie-react-native/lottie-react-native

0.0 2.0 0.0 7.54 MB

Lottie wrapper for React Native.

License: Apache License 2.0

JavaScript 28.93% Python 4.50% Java 40.00% Ruby 2.77% Objective-C 23.80%

lottie-react-native's Introduction

Lottie for React Native, iOS, and Android

npm Version License Build Status

Lottie component for React Native (iOS and Android)

Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations exported as JSON with bodymovin and renders them natively on mobile!

For the first time, designers can create and ship beautiful animations without an engineer painstakingly recreating it by hand. They say a picture is worth 1,000 words so here are 13,000:

Example1

Example2

Example3

![Community](docs/gifs/Community 2_3.gif)

Example4

All of these animations were created in After Effects, exported with bodymovin, and rendered natively with no additional engineering effort.

Related Projects

This project is only the code to wrap and expose Lottie to React Native. The parsing/rendering code can be found in their respective libraries:

Lottie for iOS

Lottie for Android

Installation

Get started with Lottie by installing the node module:

npm i --save lottie-react-native

From here, RN's built in linking should work:

react-native link lottie-react-native

If you're using CocoaPods on iOS, you can put the following in your Podfile:

pod 'lottie-react-native', :path => '../node_modules/lottie-react-native'

Please file an issue if you have any trouble!

Basic Usage

See full component API

Lottie's animation progress can be controlled with an Animated value:

import React from 'react';
import { Animated } from 'react-native';
import Animation from 'lottie-react-native';

export default class BasicExample extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      progress: new Animated.Value(0),
    };
  }

  componentDidMount() {
    Animated.timing(this.state.progress, {
      toValue: 1,
      duration: 5000,
    }).start();
  }

  render() {
    return (
      <Animation
        style={{
          width: 200,
          height: 200,
        }}
        source={require('../path/to/animation.json')}
        progress={this.state.progress}
      />
    );
  }
}

Additionally, there is an imperative API which is sometimes simpler.

import React from 'react';
import Animation from 'lottie-react-native';

export default class BasicExample extends React.Component {
  componentDidMount() {
    this.animation.play();
  }

  render() {
    return (
      <Animation
        ref={animation => { this.animation = animation; }}
        style={{
          width: 200,
          height: 200,
        }}
        source={require('../path/to/animation.json')}
      />
    );
  }
}

Running the Example Project

You can check out the example project with the following instructions

  1. Clone the repo: git clone https://github.com/airbnb/lottie-react-native.git
  2. Open: cd lottie-react-native and Install: npm install

For Running iOS:

  1. If you don't have CocoaPods installed, run sudo gem install cocoapods
  2. Install pods: npm run build:pods
  3. Run Example: npm run run:ios

For Running Android:

  1. Run Example: npm run run:android

Alternatives

  1. Build animations by hand. Building animations by hand is a huge time commitment for design and engingeering across Android and iOS. It's often hard or even impossible to justify spending so much time to get an animation right.
  2. Facebook Keyframes. Keyframes is a wonderful new library from Facebook that they built for reactions. However, Keyframes doesn't support some of Lottie's features such as masks, mattes, trim paths, dash patterns, and more.
  3. Gifs. Gifs are more than double the size of a bodymovin JSON and are rendered at a fixed size that can't be scaled up to match large and high density screens.
  4. Png sequences. Png sequences are even worse than gifs in that their file sizes are often 30-50x the size of the bodymovin json and also can't be scaled up.

Why is it called Lottie?

Lottie is named after a German film director and the foremost pioneer of silhouette animation. Her best known films are The Adventures of Prince Achmed (1926) โ€“ the oldest surviving feature-length animated film, preceding Walt Disney's feature-length Snow White and the Seven Dwarfs (1937) by over ten years The art of Lotte Reineger

Contributing

See the Contributors Guide

License

Apache-2.0

lottie-react-native's People

Contributors

lelandrichardson avatar ljharb avatar she-dev avatar

Watchers

 avatar  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.