This is my first project using Vuejs.
I've got my main component. In my main component I've got a data variable that is an array. For example:
export default {
name: 'example-component',
data() {
return {
options: [
{
text: {
nl: 'Jan',
en: 'John',
},
action: 'x1',
},{
text: {
nl: 'Jansen',
en: 'Doe',
},
action: 'x2',
},
],
}
},
}
In my template for this <example-component> I'm using a v-for loop inside of another component. Like shown below:
<my-other-component v-for="option in options" v-on:click.native="select(option.action)"
:key="option.id"></my-other-component>
This seems to work fine.
<my-other-component> has an animation for when it appears on the screen for the first time.
In the methods section of my example-component there's a method that sometimes empties the options array and re-populates it, with different objects, of course. If this method were to run now, the first two options would not have this animation, but a third, fourth, fifth, etc would.
So it appears as though this animation would trigger upon the first creation of a specific index in the options array.
Does anyone know why this is and how I could fix this issue?
PS: My (relevant) CSS:
.option {
animation-timing-function: linear;
animation-name: option;
animation-duration: 2.5s;
}
@-webkit-keyframes option{
0% { opacity: 0; }
75% { opacity: 0; }
100% { opacity: 1; }
}
-
EDIT 1:
Adding animation-iteration-count: infinite does not solve the issue. It simply repeats the animation. (-> The 'options' disappear and reappear every 2.5s)
EDIT 2:
I have tried to fiddle around a bit. It seems to have to do something with timing. If there's enough time between the deleting op options and adding them again the animation seems to work fine.
Also, I have tried different ways of emptying my array, IE:
this.options = [];
this.options.length = 0;
this.options.splice(0, this.options.length);
// And all the other goodness
But they all don't seem to affect this issue.
idand the:keyattribute doesn't work as expected. You must provide different value in each:key