LottieFiles / lottie-react

lottie web player as a react component
https://lottiefiles.com
MIT License
720 stars 80 forks source link

'direction' prop is not working #68

Open supergianlu opened 2 years ago

supergianlu commented 2 years ago

Adding direction={-1} nothing happen.

samuelOsborne commented 2 years ago

Hi @supergianlu, thanks for making this ticket, will work on getting a fix out shortly. In the meanwhile, you can get the animation playing in reverse this way:

import React from "react";
import "./styles.css";
import { Player } from "@lottiefiles/react-lottie-player";

class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = { lottie: null }; // initialize your state
  }

  render() {
    return (
      <div className="App">
        <Player
          lottieRef={(instance) => {
            this.setState({ lottie: instance }); // the lottie instance is returned in the argument of this prop. set it to your local state
          }}
          onEvent={(event) => {
            if (event === "load") {
              this.state.lottie.setDirection(-1);
            }
          }}
          autoplay={true}
          loop={true}
          controls={true}
          src="https://assets3.lottiefiles.com/packages/lf20_UJNc2t.json"
          style={{ height: "300px", width: "300px" }}
        ></Player>
      </div>
    );
  }
}

export default App;

sandbox here:

https://codesandbox.io/s/lottie-react-direction-test-ysj6p?file=/src/App.js

UrionBlade commented 2 years ago

Try adding keepLastFrame to the Player as props

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.

minizwergi commented 2 years ago

Something new here?

StrikerXx798 commented 1 year ago

Up issue, direction doens't worked

CTOverton commented 1 year ago

Nearing 9 months now, is the baby coming?

CTOverton commented 1 year ago

@supergianlu for your workaround, do you have a suggestion for how to do it with functional components? I couldn't seem to get it to work 🥺

mortengustafsson commented 1 year ago

I'm having the same problem. direction={-1} is not working, setting keepLastFrame doesn't help.

xdelmo commented 1 year ago

I'm having the same issue 😢

xdelmo commented 1 year ago

@supergianlu for your workaround, do you have a suggestion for how to do it with functional components? I couldn't seem to get it to work 🥺

Did you find a workaround for functional components?

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.

Oliver-Turp commented 7 months ago

Is this still not working? This has been open for an entire year....

Edit: make that two years

github-actions[bot] commented 5 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.