S
S
Sergey2021-09-08 21:24:13
css
Sergey, 2021-09-08 21:24:13

How to smoothly hide a block in react application?

Guys, tell me how to add animation to a block that opens and closes depending on the flag.

const SearchModal = ({ isOpen }) => 
  isOpen && <div className={cn('wrap', isOpen ? 'active' : 'showed')}>


.wrap {
  display: flex;
  align-items: start;
  width: 100%;
  &.active {
    animation: active .5s;
    animation-fill-mode: forwards;
    animation-iteration-count: 1;
  }
  &.showed {
    animation: active .5s;
    animation-fill-mode: forwards;
    animation-iteration-count: 1;
  }
}

@keyframes active {
  0% {
    opacity: 0;
    transform: translateY(30%);
  }

  100% {
    opacity: 1;
    transform: translateY(0%);
  }
}


Actually opening happens with animation, and is closed is not present. How to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iBird Rose, 2021-09-08
@iiiBird

https://reactcommunity.org/react-transition-group/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question