Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'direction' prop is not working #68

Open
supergianlu opened this issue Jan 28, 2022 · 13 comments
Open

'direction' prop is not working #68

supergianlu opened this issue Jan 28, 2022 · 13 comments
Labels

Comments

@supergianlu
Copy link

Adding direction={-1} nothing happen.

@samuelOsborne
Copy link
Member

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
Copy link

Try adding keepLastFrame to the Player as props

@github-actions
Copy link

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.

@github-actions github-actions bot added the stale label Apr 22, 2022
@minizwergi
Copy link

Something new here?

@github-actions github-actions bot removed the stale label Aug 19, 2022
@StrikerXx798
Copy link

Up issue, direction doens't worked

@CTOverton
Copy link

Nearing 9 months now, is the baby coming?

@CTOverton
Copy link

@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
Copy link

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

@xdelmo
Copy link

xdelmo commented Dec 16, 2022

I'm having the same issue 😢

@xdelmo
Copy link

xdelmo commented Dec 18, 2022

@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
Copy link

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.

@github-actions github-actions bot added the stale label Feb 17, 2023
@Oliver-Turp
Copy link

Oliver-Turp commented Jan 20, 2024

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

Edit: make that two years

@github-actions github-actions bot removed the stale label Jan 21, 2024
Copy link

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.

@github-actions github-actions bot added the stale label Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants