Skip to content

Commit

Permalink
Fix: animation should reflect loop updates (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
felippenardi authored Jun 10, 2020
1 parent cad5e36 commit 70151bb
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import React from 'react';
import PropTypes from 'prop-types';
import lottie from 'lottie-web';
import lottieApi from 'lottie-api/dist/lottie_api';
import React from "react";
import PropTypes from "prop-types";
import lottie from "lottie-web";
import lottieApi from "lottie-api/dist/lottie_api";

export default class Lottie extends React.Component {
componentDidMount() {
const {
options,
eventListeners,
} = this.props;
const { options, eventListeners } = this.props;

const {
loop,
autoplay,
animationData,
path,
renderer = 'svg',
renderer = "svg",
rendererSettings,
assetsPath,
} = options;
Expand All @@ -28,7 +25,7 @@ export default class Lottie extends React.Component {
autoplay: autoplay !== false,
animationData,
rendererSettings,
assetsPath
assetsPath,
};

this.options = { ...this.options, ...options };
Expand Down Expand Up @@ -62,6 +59,10 @@ export default class Lottie extends React.Component {
}

componentDidUpdate(prevProps) {
if (this.props.options.loop !== undefined) {
this.anim.loop = this.props.options.loop;
}

if (this.props.isStopped) {
this.stop();
} else if (this.props.segments) {
Expand Down

0 comments on commit 70151bb

Please sign in to comment.