I
I
Igor Bezlepkin2019-07-08 17:19:45
Vue.js
Igor Bezlepkin, 2019-07-08 17:19:45

How to animate removal from reactive DOM in VUE?

Hello! Tell me such a thing.
There is a reactive DOM:

<ul>
  <li></li>
  <li></li>
  <li></li>
</ul>

I give the second element a class, and then a second later I remove the reactive DOM as well. It turns out that the second element is removed from the reactive house and my class is transferred to the third element.
I basically need to do the removal with animation...
https://jsfiddle.net/8m2qtbzx/

Answer the question

In order to leave comments, you need to log in

3 answer(s)
0
0xD34F, 2019-07-08
@Bezlepkin

Replace olwith transition-group:

<transition-group tag="ol" name="todo">
  <li
    v-for="(todo, i) in todos"
    :key="todo.id"
    @click="todos.splice(i, 1)"
  >{{ todo.text }}</li>
</transition-group>

And add styles:
li {
  transition: all 0.7s;
}

.todo-leave-active {
  position: absolute;
}

.todo-leave-to {
  transform: translateX(500px);
  opacity: 0;
}

https://jsfiddle.net/8j5ygb7n/

A
Artur Karapetyan, 2019-07-08
@architawr

poke?

I
Igor Bezlepkin, 2019-07-08
@Bezlepkin

This is how it is also transferred https://jsfiddle.net/jk8tm7yw/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question