I am working on a small Todo App with Vue 3. I want the appending of a new to-do item to be smooth, not instantaneous.
For this purpose, I have added the class active to the latest to-do item:
<template>
<ul class="todo-list" v-if=dataIsLoaded>
<TodoItem v-for="(todo, index) in todos.slice().reverse()"
:key="todo.id"
:class="{done: todo.completed, active: index == 0}"
:todo="todo"
@delete-todo="$emit('delete-todo', todo.id)"
@toggle-todo="$emit('toggle-todo', todo)"
/>
</ul>
<div class="loader" v-else></div>
</template>
In the CSS I have:
li:first-child {
opacity: 0;
transform: translateX(-295px);
transition: all 0.3s ease;
}
li.active {
opacity: 1;
transform: translateX(0);
}
It does not work as I expected hoped. It might be because the CSS is loaded late, it might be for another reason I was unable to figure out.
What is the easiest solution to this problem?