beekai-oss / react-simple-animate

🎯 React UI animation made easy
https://react-simple-animate.now.sh/
MIT License
1.82k stars 61 forks source link

Animation does not play back #73

Closed osadasami closed 4 years ago

osadasami commented 4 years ago

Animation does not play back after second click

I have this component

import React from "react"
import { useAnimate } from "react-simple-animate"

export default () => {
  const { play, style, isPlaying } = useAnimate({
    start: { transform: "translateX(0px)" },
    end: { transform: "translateX(200px)" }
  });

  function handleClick() {
    play(!isPlaying)
    console.log('isPlaying: ', isPlaying)
  }

  return (
    <>
      <div style={style}>
        Hello
      </div>
      <button onClick={handleClick}>
        Play
      </button>
    </>
  );
}

I expect that animation will play back after second click but it doesn't and only after double click it plays back

Check gif

Package version

"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.3",
"react-simple-animate": "^3.3.9"
bluebill1049 commented 4 years ago

Do you have a codesandbox?

osadasami commented 4 years ago

Create sandbox to demonstrate and same problem there https://codesandbox.io/s/keen-pond-mqxhw?file=/src/App.js