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

Custom animations on react-responsive-modal-modal #479

Open
Link2Twenty opened this issue Jun 17, 2021 · 0 comments
Open

Custom animations on react-responsive-modal-modal #479

Link2Twenty opened this issue Jun 17, 2021 · 0 comments
Labels

Comments

@Link2Twenty
Copy link

Bug report

Describe the bug

If you want to have a custom animation on your modal window, such as a shake for incorrect password entry, you cannot because the fade in and out styles are added to the element with JS.

To Reproduce

Some code like this shows the problem (codesandbox).

const [classList, setClassList] = useState([]);

<Modal classNames={{ modal: classList }} open={open} onClose={()=>{}}>
  <button onClick={() => {
    setClassList(array => [...array, "custom-animation"])
  }}>
    Shake it
  </button>
</Modal>
.custom-animation {
  animation: shakeit 500ms linear;
}

@keyframes shakeit {
  8%,
  41% {
    transform: translateX(-10px);
  }

  25%,
  58% {
    transform: translateX(10px);
  }

  75% {
    transform: translateX(-5px);
  }

  92% {
    transform: translateX(5px);
  }

  0%,
  100% {
    transform: translateX(0);
  }
}

Expected behaviour

When the fade animation finished the style should be removed from the element

Screenshots

N/A

System information

N/A

Additional context

There is a work around I use at the moment but it would be nicer if the component handled it (codesandbox).

const onFinishFade = () => {
  const { current } = modalBox;

  current.style.animation = null;
};
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

1 participant