animate-css-styled-components icon indicating copy to clipboard operation
animate-css-styled-components copied to clipboard

Trigger animation when playState changes from "paused" to "running" - stacked component

Open d-fal opened this issue 5 years ago • 3 comments
trafficstars

I want to trigger a ZoomOutDown to a component when a button fires. When I change the playState from "paused" to "running", nothing happens. Can you help how to do this?

` 

  <Animate
    duration="1s"
    iterationCount={100}
    playState={animateState}
    delay="1s"
    Animation={[ZoomOutDown]}
  >
  <button
    onClick={(e) => {
      e.preventDefault();
      setAnimateState("running");
    }}
  >
    Click
  </button>
 </Animate>

`

d-fal avatar Jul 25 '20 20:07 d-fal

@d-fal sorry for the big delay on it.

in order to do that, you should only render the Animate component if the state is equal running in a declarative way, for now, there is no playState prop, although this is a valid idea to implement. will definitely add it to the backlog.

dielduarte avatar Nov 27 '20 04:11 dielduarte

Hey @d-fal, Just got exactly what is happening!

We have a bug to control animation props when using stacked animations, on your example, you are passing the animation like: Animation={[ZoomOutDown]} try this way: Animation={ZoomOutDown}, not setting it as an array will only render the animation component instead of the stack animation component and the switch between paused or running will work as expected.

dielduarte avatar Dec 13 '20 00:12 dielduarte

@dielduarte, thanks for following this up. I would try this and report it back. Btw, it made me go deeper in reactjs animation and transition group. I would try to contribute to this project if I could.

d-fal avatar Dec 13 '20 01:12 d-fal