Giter Club home page Giter Club logo

react-lottie's Introduction

Lottie Animation View for React (Angular, Vue)

npm version

Demo

https://chenqingspring.github.io/react-lottie

Wapper of bodymovin.js

bodymovin is Adobe After Effects plugin for exporting animations as JSON, also it provide bodymovin.js for render them as svg/canvas/html.

Why Lottie?

Flexible After Effects features

We currently support solids, shape layers, masks, alpha mattes, trim paths, and dash patterns. And we’ll be adding new features on a regular basis.

Manipulate your animation any way you like

You can go forward, backward, and most importantly you can program your animation to respond to any interaction.

Small file sizes

Bundle vector animations within your app without having to worry about multiple dimensions or large file sizes. Alternatively, you can decouple animation files from your app’s code entirely by loading them from a JSON API.

Learn morehttp://airbnb.design/lottie/

Looking for lottie files › https://www.lottiefiles.com/

Installation

Install through npm:

npm install --save react-lottie

Usage

Import pinjump.json.json as animation data

import React from 'react'
import Lottie from 'react-lottie';
import * as animationData from './pinjump.json'

export default class LottieControl extends React.Component {

  constructor(props) {
    super(props);
    this.state = {isStopped: false, isPaused: false};
  }

  render() {
    const buttonStyle = {
      display: 'block',
      margin: '10px auto'
    };

    const defaultOptions = {
      loop: true,
      autoplay: true, 
      animationData: animationData,
      rendererSettings: {
        preserveAspectRatio: 'xMidYMid slice'
      }
    };

    return <div>
      <Lottie options={defaultOptions}
              height={400}
              width={400}
              isStopped={this.state.isStopped}
              isPaused={this.state.isPaused}/>
      <button style={buttonStyle} onClick={() => this.setState({isStopped: true})}>stop</button>
      <button style={buttonStyle} onClick={() => this.setState({isStopped: false})}>play</button>
      <button style={buttonStyle} onClick={() => this.setState({isPaused: !this.state.isPaused})}>pause</button>
    </div>
  }
}

props

The <Lottie /> Component supports the following components:

options required

the object representing the animation settings that will be instantiated by bodymovin. Currently a subset of the bodymovin options are supported:

loop options [default: false]

autoplay options [default: false]

animationData required

rendererSettings required

width optional [default: 100%]

pixel value for containers width.

height optional [default: 100%]

pixel value for containers height.

eventListeners optional [default: []]

This is an array of objects containing a eventName and callback function that will be registered as eventlisteners on the animation object. refer to bodymovin#events where the mention using addEventListener, for a list of available custom events.

example:

eventListeners=[
  {
    eventName: 'complete',
    callback: () => console.log('the animation completed:'),
  },
]

Related Projects

Contribution

Your contributions and suggestions are heartily welcome.

License

MIT

react-lottie's People

Contributors

arvinh avatar babygoat avatar blakedietz avatar chenqingspring avatar dalerasrorov-eb avatar jakeleboeuf avatar jchen-eb avatar jcrben avatar jwfwessels avatar oblador avatar ryanponce avatar sahajr avatar simchashats avatar timhau avatar tpae avatar yagolopez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-lottie's Issues

Destroy Lottie on 'complete' event.

I'm having issue's on destroying Lottie, it doesn't seem to be as straightforward as it is in lottie-web.

This is my Lottie with eventlistener.

const eventListeners: EventListener[] = [
	{
		eventName: 'complete',
		callback: () => (event.target as unknown as Lottie).destroy()
	}
]

<Lottie options={introOptions} speed={1} isClickToPauseDisabled={true} eventListeners={eventListeners} />

Any idea on how I can achieve this?

TypeError: Cannot set property 'fillStyle' of null

Hey guys

First of all, thanks for your job with this, is really amazing and easy to use

I'm having this issue when I'm trying to test a component where I'm using react-lottie, also, keep in mind that this is happening when jest is trying to import Lottie. This is my component:

MyComponent.js

import React from 'react';
import Lottie from 'react-lottie';
mport loaderAnimation from './loaderData.json';
import profileAnimation from './profileData.json';

class AnimatedImages extends PureComponent {
  getAnimationData = () => {
    const { image } = this.props;
    switch (image) {
      case 'loader':
        return loaderAnimation;

      case 'profile':
        return profileAnimation;

      default:
        return loaderAnimation;
    }
  };

  render() {
    const { loop } = this.props;
    return (
      <div className="loader-wrapper">
        <Lottie
          options={{
            animationData: this.getAnimationData(),
            loop,
            autoplay: true
          }}
        />
      </div>
    );
  }
}

And my test file

MyComponent.spec.js

import React from 'react';
import { shallow, mount } from 'enzyme';
import MyComponent from './MyComponent';

jest.mock('lottie-web'); // I have tried mock the animation data, nothing
jest.mock('react-lottie');

describe('Animated images component', () => {
  it('should render with crashing', () => {
    const component = shallow(<AnimatedImages />); // I have tried it with mount, but nothing
    expect(component).toBeDefined();
  });
});

Once I run the test I got the error mentioned above and I'm not able to test the component properly.
It will be great if you guys mention, if I'm doing something wrong, in your documentation the proper way to do unit tests for the components made with react-lottie. I saw your code and I notice that you have a test file, but I think is not very accurate for this particular case.

Let me know, if I'm doing something wrong, if not, I think that this is probably a bug for the component.

Thank you guys in advance!

Event listener for animation complete not available.

Attempting to trigger a function to re-direct the page after the animation is completed. Perhaps we are not understanding how to pull event hooks in the wrapper, however at the moment we cannot find an onComplete or similar event hook.

This repo is dead

It appears this repo is dead. Also, author @chenqingspring hasn't been active since 2018.

Anyone want to fork this lib and start fresh? 🙏

SSR still broken

I still cannot get this thing to work SSR. Running locally with no problems
Oh and I needed to add typescript interface from #34 but this shouldn't cause that error
react-lottie = v1.2.3, lottie-web=v5.2.1
lotttie

Animation plays itself when a state changes

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

First I'm rendering an animation with autoplay set to false.
this.options = { loop: false, autoplay: false, animationData: require("./leo_anim.json"), rendererSettings: { preserveAspectRatio: "xMidYMid slice" } };

The animation does not start which is perfect, but then I call setState() function and the animation starts playing

See the behavior here: https://codesandbox.io/s/2wk6nv3pvr

What is the expected behavior?

If the animation has autoplay set to false, then it should only start when the play function is called.

Which versions of Lottie

Both "react-lottie": "1.0.0" & "react-lottie": "1.1.0"

Thank you for your help!

How to trigger animation on hover?

Currently trying to do it using the following but to no avail:

      <Lottie options={defaultOptions}
        height={100}
        width={100}
        isStopped={hover['isStopped']}
        direction={hover['direction']}
        eventListeners={
        	[
                { eventName: 'onMouseOver', callback: () => mouseOn() },
        	{ eventName: 'onMouseLeave', callback: () => mouseOut() }
        	]
        }
      />

Basically goal was to trigger the animation on hover, then reverse the animation when leaving.

Bump to 1.0.0 is tricky - publish 0.2.6 to npm?

Hey, I'm a teammate of @dokinoki (#20 is our only current use) - we are using this and found that the bump to 1.0.0 caused issues (not sure about the details), but we want to upgrade to React v16 without peerDependency warnings.

Could you publish 0.2.6 to npm?

动画

第一次进入点击元素会做动画的,怎么禁止?

Question: will reload animation be supported?

I have the need to switch between 2 animations, and found that bodymovin.loadAnimation is done in componentDidMount, so I have to change the key of Lottie component to enforce React to create a new instance.

Will there be a reloadAnimation or something like it so that the Lottie component could meet this need?

Thanks.

Unsafe hook componentWillUpdate

Hi guys
I've just enabled React.strictMode for my app and the only warning I get is related to Lottie

index.js:1446 Warning: Unsafe lifecycle methods were found within a strict-mode tree:
    in StrictMode

componentWillUpdate: Please update the following components to use componentDidUpdate instead: Lottie

Learn more about this warning here:
https://fb.me/react-strict-mode-warnings

That's the indicted code, is there a safe way to remove the hook without compromising how Lottie work?

Thank you for all 😊
Stefano

Play Segments question

Is it possible to use it?

If so, someone can enlighten me or point me where to find more info or demo =)

Thank you!!

Any solution to minimize bodymovin?

As bodymovin is huge, could react-lottie add a prop to control which version of bodymovin to use?
I mean, like 'full', 'min' (bodymovin.min), 'light' (bodymovin_light.min).
For example, if I only need bodymovin to support svg, do we have a way to require bodymovin_light.min, and make compiled js file as small as possible?
Thanks!

Lottie JSON with Images png/Base64

Good Morning,
I'm trying to attach my Json with png/Base64 images, but i'm getting this error:

Uncaught SyntaxError: Invalid or unexpected token
at eval (eval at initiateExpression (lottie.js:14109), :4:2791)
at _expression_function (eval at initiateExpression (lottie.js:14109), :34:2)
at ValueProperty.executeExpression (lottie.js:14418)
at ValueProperty.processEffectsSequence [as getValue] (lottie.js:2688)
at GroupEffect.iterateDynamicProperties (lottie.js:399)
at IImageElement.prepareProperties (lottie.js:8143)
at IImageElement.prepareFrame (lottie.js:8395)
at SVGCompElement.ICompElement.prepareFrame (lottie.js:9443)
at SVGCompElement.ICompElement.prepareFrame (lottie.js:9443)
at SVGCompElement.ICompElement.prepareFrame (lottie.js:9443)
at SVGRenderer.renderFrame (lottie.js:7064)
at AnimationItem.renderFrame (lottie.js:13238)
at AnimationItem.gotoFrame (lottie.js:13230)
at AnimationItem.checkLoaded (lottie.js:13206)
at AnimationItem.waitForFontsLoaded (lottie.js:13187)
at AnimationItem.configAnimation (lottie.js:13178)
at AnimationItem.setParams (lottie.js:13013)
at Object.loadAnimation (lottie.js:12774)
at Object.loadAnimation (lottie.js:16489)
at Lottie.componentDidMount (index.js:95)
at commitLifeCycles (react-dom.development.js:18115)
at commitAllLifeCycles (react-dom.development.js:19674)
at HTMLUnknownElement.callCallback (react-dom.development.js:147)
at Object.invokeGuardedCallbackDev (react-dom.development.js:196)
at invokeGuardedCallback (react-dom.development.js:250)
at commitRoot (react-dom.development.js:19898)
at react-dom.development.js:21446
at Object.unstable_runWithPriority (scheduler.development.js:255)
at completeRoot (react-dom.development.js:21445)
at performWorkOnRoot (react-dom.development.js:21368)
at performWork (react-dom.development.js:21273)
at performSyncWork (react-dom.development.js:21247)
at requestWork (react-dom.development.js:21102)
at retryTimedOutBoundary (react-dom.development.js:20782)
at wrapped (scheduler-tracing.development.js:177);

After some debug, i found where error appear:
expression_function(); // HERE
this.frameExpressionId = elem.globalData.frameId; //TODO: Check if it's possible to return on ShapeInterface the .v value // JUST FOR REFERENCE ON CODE

And here is lottie "Function" returned:
[function _expression_function(){var $bm_rt;
$bm_rt = function () {
var fxs = ['G06#3#1'];
eval(['@JSXBIN@ES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fRCVMfDFeBhRffnftJiDnASzGjPjVjUiPjCjKgeCEjUfRCVMfDFeBhSffnftZiEnAUzChGhGgfCzChehdhAjzEjUjJjNjFhBfXDfVgdfBnnCzBhchCjhBfCLXDfVgefCXFfVgefCnnnnnnAEM40BhAV40BiAgd4B0AiAge4C0AiABDAzGjJjTiGjYiFjOhDAiFFOIbyJn0ABJJnABjRfjzJjUjIjJjTiMjBjZjFjShEfnfACSizGjUjZjQjFjPjGhFjRfnneJjVjOjEjFjGjJjOjFjEnJRnASKyBWCAnftOiHbiIn0ADaiIbiKn0ADJiKnASzBjNhGyBEXzDjLjFjZhHfXzGjNjBjSjLjFjShIfjRfRBVzBjJhJfyBffnftJiLnASzBjQhKyBXzKjQjBjSjBjNjFjUjFjSjThLfVhGfyBnftOiObiQn0ADOiQDiQnAJfACYXzgfjajajajajajajajajajajajajajajaifiBiDiNjBjSjLjFjSiFjOjBjCjMjFjEhMfVhKfyBnneBhRnJiSnASzKjQjSjFjTjFjUiUjZjQjFhNyBXzhFjajajajajajajajajajajajajajajaifiBiDiNjBjSjLjFjSiBjQjQiQjSjFjTjFjUiUjZjQjFhOfVhKfyBnftOiUbiWn0AFJiWnASNyBXzgcjajajajajajajajajajajajajajajaifiBiDiNjBjSjLjFjSiUjZjQjFhPfVhKfyBnftJiXnASMyBXzhCjajajajajajajajajajajajajajajaifiBiDiNjBjSjLjFjSiQjSjFjTjFjUiDjPjEjFhQfVhKfyBnftJiYnASIyBnbftOiaJibnASIyBXzgcjajajajajajajajajajajajajajajaifiBiDiNjBjSjLjFjSiFjBjTjFhRfVhKfyBnffAEXPfVhKfyBRBFegcjajajajajajajajajajajajajajajaifiBiDiNjBjSjLjFjSiFjBjTjFffnJidnAEjOfRFVMfyBVNfyBXhBfVhGfyBXzIjEjVjSjBjUjJjPjOhSfVhGfyBVIfyBffACSVhNfyBnneBhTnAUgfUgfEXPfVhKfyBRBFegfjajajajajajajajajajajajajajajaifiBiDiNjBjSjLjFjSiFjOjBjCjM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jPjOjUjSjPjMjTFeJiJjOjUjFjOjTjJjUjZFdjEffnndjEnfAXzCjFjOGfjDfn0DzAHByB'][0]);
eval(['@JSXBIN@ES@2.0@MyBbyBn0ABOAbAn0ABJAnAEjzIjBjDiWjBjMiBjEjEBfRBCzBhKChzBhNDjzMjUjIjJjTiQjSjPjQjFjSjUjZEfCzBhNFnCCXzEjGjBjEjFGfjzCjBjDHfXzJjJjOjUjFjOjTjJjUjZIfjHfnndBnnnffAXzCjFjOJfjHfn0DzAKByB'][0]);
eval(['@JSXBIN@ES@2.0@MyBbyBn0ABOAbAn0ABJAnAEjzIjBjDiWjBjMiTjFjUBfRBFdAffAhzBhBCXzCjFjODfjzCjBjDEfn0DzAFByB'][0]);
eval(['@JSXBIN@ES@2.0@MyBbyBn0AEJAnABjzBjWBfXzFjWjBjMjVjFCfjzMjUjIjJjTiQjSjPjQjFjSjUjZDfnfOBbyCn0ABJCnABjBfEjzFjBjDjNjVjMEfRCjBfjzIjBjDiNjVjMiWjBjMFfffnfACzChdhdGjzQjBjDiNjVjMjUjJjQjMjJjDjBjUjJjWjFHfnnctbEn0AEOEbyFn0ABJFnABjBfCzBhKInnndAntACGjzIjBjDiTjFjUiBjWjHJfnnctnOIbyJn0ABJJnABjBfCzBhLKnXzLjBjOjDjIjPjSiQjPjJjOjULfjzJjUjSjBjOjTjGjPjSjNMfnnntAjzHjBjDiBjEjEiBiQNfnOMJNnAPjzIjBjDiBjWjHiDjOjUOfyBtACzBhePjzLjXjFjJjHjIjUjFjEiDjOjUQfnndBnOPbQn0ACJQnABjzIjBjDiBjWjHiWjBjMRfCzBhPSjRfjOfnnnfJRnABjBfCKnjRfnnntACPjOfnndAnJVnABjBfCKnjzIjBjDiBjEjEiWjBjMTfnnntJXnAjBf0DzAUByB'][0]);
return v;
}();;scoped_bm_rt=$bm_rt}]

I don't know if i'm doing something wrong, or this plugin don't support png/Base64 images

Thx in advance and great job with this plugin.

Cannot read property 'length' of undefined at SVGRenderer.configAnimation

I know many people got the same error but I have a weird situation. I got this error when I migrated to webpack 4 from webpack 2. It was working fine in webpack 2. I am using exact same version number and animation file just the web pack version is different.

I read in other similar [issues] (airbnb/lottie-web#1120) and some suggested it's because of uglification but when I looked at the source, I found this in (bodymovin.js:5720)
this.elements = Array.apply(null,{length:animData.layers.length})

it doesn't seems to be uglified. I think the problem is in the lottie-web not in this wrapper. Any idea?

Uncaught TypeError: Cannot read property 'length' of undefined

Hi first I just discovered this wrapper, great work!

I've been having this problem for a while now: one of my animations keeps giving me:
Uncaught TypeError: Cannot read property 'length' of undefined

I tried using different bodymovin/lottie versions, none of them works, including this one.

My json file is in the attachment, can someone please have a look at it and tell me what's wrong with it? Thanks in advance for answer!
Group1Image7BatteriesV3.zip

Modernize with Hooks and Babel 7 (PR)

I have a PR (which is on lottie-react-web which is a fork of react-lottie) which is a rewrite with Hooks and Babel 7: felippenardi/lottie-react-web#17

Since both lottie-react-web and react-lottie aren't updated very often, I open to making my own official spin-off, but preferable I'd like to be a contributor to one of these upstream sources.

can not pause

creatLottie1() { const { json } = this.props.store.toJS(); const options = { renderer: 'svg', loop: false, autoplay: false, animationData: json.deom1 } return ( <div> <Lottie options={options} ref={ref => { this.singalLottie = ref; }} height={'100vw'} width={'100vw'}/> <div className="p-animation__btn-wrap"> <button className="p-animation__lottie-btn" onClick={() => { this.singalLottie.stop(); }}>stop</button> <button className="p-animation__lottie-btn" onClick={() => { this.singalLottie.play(); }}>play</button> <button className="p-animation__lottie-btn" onClick={() => { if(this.state.isPaused) this.singalLottie.play(); if(!this.state.isPaused) this.singalLottie.pause(); this.setState({isPaused: !this.state.isPaused}) }}>pause</button> </div> </div> ) }
when I click pause, the lottie will restart,whether the state.isPaused it should be paused 0 0

setSpeed is not called with initial speed

If I do something like

<Lottie options={options} height={250} width={250} speed={0.5} />

the animation will run with the default speed, not 0.5 as intended. This is because setSpeed is not called in componentDidMount(), only in componentDidUpdate().

Build tooling based on old version of CDK/storybook

npm build scripts are based on an old version of React storybook that does not run on windows

the build scripts in the current version of react storybook are js files instead of bash scripts which allows cross-plat development

Multiple animations on the same page crashes the browser

Some animations cause some type of infinite loop that crashes the browser. Here is an example of a JSON animation export that, by itself works fine, but crashes when adding multiple in the same page.

{"v":"4.12.0","fr":29,"ip":0,"op":45,"w":1920,"h":1080,"nm":"Progress Bar","ddd":0,"assets":[],"fonts":{"list":[{"origin":0,"fPath":"","fClass":"","fFamily":"Helvetica","fWeight":"","fStyle":"Regular","fName":"Helvetica","ascent":75}]},"layers":[{"ddd":0,"ind":1,"ty":5,"nm":"Percentage Text","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":0,"s":[0],"e":[100]},{"t":38}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[894,466,0],"ix":2},"a":{"a":0,"k":[19,-12,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"n":["0p833_0p833_0p167_0p167","0p833_0p833_0p167_0p167","0p833_0p833_0p167_0p167"],"t":0,"s":[387.818,400,100],"e":[581.727,600,100]},{"t":38}],"ix":6}},"ao":0,"t":{"d":{"k":[{"s":{"s":48,"f":"Helvetica","t":"58","j":0,"tr":0,"lh":57.6,"ls":0,"fc":[0.1,0.74,0.61]},"t":0}]},"p":{},"m":{"g":1,"a":{"a":0,"k":[0,0],"ix":2}},"a":[]},"ip":0,"op":45,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":5,"nm":"Percentile Text","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":0,"s":[0],"e":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":30,"s":[0],"e":[100]},{"t":38}],"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":30,"s":[-40],"e":[0]},{"t":38}],"ix":10},"p":{"a":0,"k":[1106,402,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[200,190.692,100],"ix":6}},"ao":0,"t":{"d":{"k":[{"s":{"s":60,"f":"Helvetica","t":"th","j":0,"tr":0,"lh":72,"ls":0,"fc":[0.1,0.74,0.61]},"t":0}]},"p":{},"m":{"g":1,"a":{"a":0,"k":[0,0],"ix":2}},"a":[]},"ip":0,"op":45,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"Front Circle","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[960,540,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":1,"k":[{"i":{"x":[0.833,0.833],"y":[0.833,0.833]},"o":{"x":[0.167,0.167],"y":[0.167,0.167]},"n":["0p833_0p833_0p167_0p167","0p833_0p833_0p167_0p167"],"t":0,"s":[41.67,41.67],"e":[12.603,66.67]},{"t":38}],"ix":2},"p":{"a":0,"k":[0,-400],"ix":3},"r":{"a":0,"k":0,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":0,"ix":5},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.101960784314,0.737254901961,0.611764705882,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"rp","c":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":0,"s":[0],"e":[275]},{"t":38}],"ix":1},"o":{"a":0,"k":0,"ix":2},"m":1,"ix":4,"tr":{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":1,"ix":4},"so":{"a":0,"k":100,"ix":5},"eo":{"a":0,"k":100,"ix":6},"nm":"Transform"},"nm":"Repeater 1","mn":"ADBE Vector Filter - Repeater","hd":false},{"ty":"tr","p":{"a":0,"k":[0,-27.9],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 1","np":4,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":45,"st":0,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"Background Circle","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[960,540,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[6.176,32.67],"ix":2},"p":{"a":0,"k":[0,-400],"ix":3},"r":{"a":0,"k":0,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"st","c":{"a":0,"k":[0.756862745098,0.756862745098,0.756862745098,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.756862745098,0.756862745098,0.756862745098,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"rp","c":{"a":0,"k":360,"ix":1},"o":{"a":0,"k":0,"ix":2},"m":1,"ix":4,"tr":{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":1,"ix":4},"so":{"a":0,"k":100,"ix":5},"eo":{"a":0,"k":100,"ix":6},"nm":"Transform"},"nm":"Repeater 1","mn":"ADBE Vector Filter - Repeater","hd":false},{"ty":"tr","p":{"a":0,"k":[0,-27.9],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 1","np":4,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":45,"st":0,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":"Background White","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[960,540,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[786.668,811.699],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.756862745098,0.756862745098,0.756862745098,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[2.795,-19.482],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":45,"st":0,"bm":0}]}

NPM version requires ^3.0.0

Description

This library requires the carat (^) of npm for 3.0.0 -> ^3.0.0

this causes issues for any packages consuming this library that require newer versions of npm because the ^ indicates that the left-most (major) version cannot be increased.

is there any reason we can't remove this restriction? or do newer versions of npm break this library?

Setting renderer to 'canvas'?

Hi there,

I'm trying to set react-lottie to use canvas instead of SVG, however from my research it seems the feature has not yet been included. If you could point me in the right direction I'd be happy to make a PR.

State change causes animation to pause

Issue

I'm rendering a loading animation, while my results are being fetched. Right before the results appear, the animation hangs, until the new results appear, and the animation is unmounted.

Expected Behaviour

The animation should keep on loading without a pause, and the results should appear whenever they do, but without having the animation paused.

I was previously using a circular progress material-ui component which is simply a circular rotating loader and the loader would keep looping, and the results would appear, without the user noticing that the loader unmounted.

Has anyone come across such an issue? I would appreciate any input that could help me debug.

Cannot create property 'tf' on string

I am getting this in my react app

Cannot create property 'tf' on string '/./plugin-config/preloader.json'

Another error I am getting is

index.js:164 Uncaught TypeError: Cannot read property 'destroy' of undefined at Lottie.destroy

My setup include webpack 4 and React 16. I think the issue is with the animationData as when I hide it it works.

Whole component flashes/glitches after 5 seconds

I am getting this weird issue where my whole component which I am animating is glitching or flashing after 5 seconds. Here are my default options:

const defaultOptions = {
      loop: true,
      autoplay: true,
      animationData,
      rendererSettings: {
        preserveAspectRatio: 'xMidYMid slice',
      },
    };

and here's my react-lottie component:

<Lottie
                    options={defaultOptions}
                    height={400}
                    width={400}
                    isClickToPauseDisabled
                  />

pauses when clicked despite isPaused={false} and isStopped={false}

Why does my animation pause when clicked despite isPaused={false} and isStopped={false}?

      <Lottie options={{
          loop: true,
          animationData: tunnelVision,
          rendererSettings: { preserveAspectRatio: 'xMidYMid slice' }
          }}
          height={'100%'}
          width={'100%'}
          isStopped={false}
          isPaused={false}/> 

Support `goToAndStop`?

Hi there,

I'm interested in being able to set the exact frame of the animation, so that I can sync the animation as the user scrolls down the page.

For now, I've created a subclass of Lottie that takes a percentage parameter and then uses it to set the frame:

export default class LottieWithAnimationControl extends Lottie {
  static propTypes = {
    ...Lottie.propTypes,
    percentage: PropTypes.number,
  }

  anim: any
  props: Props

  componentDidUpdate(prevProps: Props, prevState: any, prevContext: any) {
    if (super.componentDidUpdate) {
      super.componentDidUpdate(prevProps, prevState, prevContext)
    }

    if (this.props.percentage !== prevProps.percentage && this.anim.totalFrames) {
      const frame = Math.round(this.anim.totalFrames * this.props.percentage)
      this.anim.goToAndStop(frame, true)
    }
  }
}

However, what do you think of supporting this natively in the component?

Lottie renders a div which is an invalid child of p

When using Lottie as a child of a paragraph tag React logs a warning:

Warning: validateDOMNesting(...): <div> cannot appear as a descendant of <p>.

Should the component accept a prop which would allow the user to choose which element to render?

controlling padding

hello !
I downloaded some lottie files from the platform but some of these have a really huge padding. any idea how to control that ?

Question: Controlling animation state within a button

First of all, THANK YOU for creating this :) Super easy to plug into my react app and get lottie-ing :)

Just wondering how best to implement a clickable 'like' button like the twitter example. Most things I see are all loops and i'm unsure how to get the animation to pause/stop.

I thought what i could do was start with loop: false, autoplay: false and my initial state isStopped: true. Then onClick: basically just set isStopped to false as well, so that way the heart would go from grey to pink, then stop.

The tricky bit next was how to either a) 'reset' it back to frame 1 or b) reverse the direction of the animation and play in reverse til it hits frame 1.

Any ideas?

Secondly, the documentation on the bodymovin repo for direction is a little vague, but from looking at your source code am i correct in assuming that -1 is reverse?

I have a rough sketch here,

export default class LottieControl extends React.Component {
    constructor(props) {
        super(props);
        this.state = { isPaused: true, isLiked: false };
    }

    handleClick = () => {
        const { isLiked } = this.state;
        if (!isLiked) {
            this.setState({ direction: 1, isPaused: false, isLiked: true });
        } else {
            this.setState({ direction: -1, isPaused: false, isLiked: false });
        }
    };

    render() {
        const buttonStyle = {
            display: 'block',
        };

        const defaultOptions = {
            loop: false,
            autoplay: false,
            animationData: animationData,
            direction: this.state.direction || 1,
        };

        return (
            <div>
                <button style={buttonStyle} onClick={this.handleClick}>
                    <Lottie
                        options={defaultOptions}
                        height={100}
                        width={100}
                        isPaused={this.state.isPaused}
                    />
                </button>
            </div>
        );
    }
}

force playSegments

There is another bool param for playSegments(segments, force), it is so handful to work with segments, please add support for force param.

How to locate /images/ for the animation

Hey there,

So we've got a data.json full of our animation data and an /images/ directory including the images that will be animated, given to us by our designer. However, I didn't see any mention of how the /images/ paths can be found through react-lottie? Unsure if this is the correct place to ask, but if anyone has come across this issue (as I myself don't know enough about After Effects - which it was exported with), could you advise?

I have seen this issue crop up on lottie-web itself and people suggest a way so that the /images/ folder doesn't appear on export, or does react-lottie have something like lottie-web, when it comes to picking up assetPaths for the .json? To ensure it finds the images.

Apologies if this seems vague, I'm just not very well versed in the design process itself.

TabIndex and Spreading Props

Expected result

I have a navigation bar with multiple links. Each link consists of text and an animated icon. When a user tabs inside the navigation, the only item that has to get focused is the link itself.

Actual result

The whole links gets focused on the first tab. The animated icon inside gets focused on second tab.

Ways to fix it:

  1. Spread the incoming props to the component down to the inner div
  2. Remove the tabIndex or make it a prop

I will be more than happy to submit a pull request, if you give me green light!
Thank you for the excellent work!

add a definition file for typescript

Hi,

For some project, I use TypeScript in react. The react-lottie package is not compatible with TypeScript because TypeScript requires a variable definition file to work properly (FlowType also uses it for variable definitions).

I propose a draft definition file (I'm not sure it's 100% compatible with your code)

declare module 'react-lottie' {
  /**
   * @param loop if the animation must be continue after the animation has fully executed
   * @param autoplay if the animation needs to be started when the react component requests rendering
   * @param animationData require here the animation data in format JSON
   * @param rendererSettings
   */
  interface LottieBodymovinOptionProps {
    loop?: boolean,
    autoplay?: boolean,
    animationData: any,
    rendererSettings?: {
      preserveAspectRatio?: any
      context?: any, // the canvas context
      scaleMode?: 'noScale' | any,
      clearCanvas?: boolean,
      progressiveLoad?: boolean, // Boolean, only svg renderer, loads dom elements when needed. Might speed up initialization for large number of elements.
      hideOnTransparent?: boolean, //Boolean, only svg renderer, hides elements when opacity reaches 0 (defaults to true)
      className?: string,
    }
  }

  /**
   * @param eventName the event sent by bodymovin
   * @param callback a callback execute when this eventName is received.
   */
  interface BodymovinEvent {
    eventName: 'complete' | 'loopComplete' | 'enterFrame' | 'segmentStart' | 'config_ready' | 'data_ready' | 'loaded_images' |
    'DOMLoaded' | 'destroy',
    callback: () => void,
  }

  /**
   * Props of Lottie component
   * @param options the object representing the animation settings that will be instantiated by bodymovin.
   * @param height height size of the animation in pixel, default value is 100%
   * @param width width size of the animation in pixel, default value is 100%
   * @param isStopped must be stocked in a state, boolean that describe if the animation must be in stopped mode
   * @param isPaused must be stocked in a state, boolean that describe if the animation must be in paused mode
   * @param eventListeners optional [default: []], This is an array of objects containing a eventName and callback function that will be registered as eventlisteners on the animation object. refer to bodymovin#events where the mention using addEventListener, for a list of available custom events.
   */
  interface LottiePropsType {
    options: LottieBodymovinOptionProps,
    height?: number | string,
    width?: number | string,
    isStopped: boolean,
    isPaused: boolean,
    eventListeners?: Array<BodymovinEvent>
    segments?: Array<number>
    speed?: number | 1,
    direction?: number,
    ariaRole?: string | 'button',
    ariaLabel?: string | 'animation',
    isClickToPauseDisabled?: boolean,
    title?: string,
  }
  /**
   * @component Lottie is a component that allow you to use animation from JSON file that created by
   * Bodymovin on Adobe After Effect
   */
  class Lottie extends React.Component<LottiePropsType, any> {}
  export default Lottie;
}

Note : this code must be in a file whose name ends in .d.ts. More documentation here

Note : you must probably add a new css rule to remove the blue outline when the mac user clicks on the animation exemple

  .myAnimationDiv {
    outline: 0;
  }

Adding images

How can I use images with react-lottie? How does the json reference the images?

Set animation progress

Hello! Just wondering if there was a way to set the animation progress, for example im going to use an animation in a button that keeps a state, so for example if the state is true, I need to set the animation to the end once the page loads. Like a favorite button, if something is already favorite, when the page loads, the button animation needs to be at the end.

Also, anyway to reset the animation to the initial frame as well?

Thank you!

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.