I'm trying to get a list/grid of items to transition with a fancy effect as seen in the Vue dcs about list transitions, I based my current code on the example given here :
From the official docs on Vue transitions.
https://vuejs.org/v2/guide/transitions.html#List-Move-Transitions
My code:
<template>
<div class="main_container" @click="shuffle()">
<transition-group name="cell" tag="div" class="container">
<div class="cell" v-border v-for="(item, index) in items" :key="index">{{ item.n }}</div>
</transition-group>
</div>
</template>
<!--SCRIPTS-->
<script>
export default {
name: "LAYOUTcard19",
data() {
return {
items: [],
};
},
mounted() {
for (let i = 0; i < 20; i++) {
let random = Math.random().toFixed(2);
let cell = { n: random };
this.items.push(cell);
}
},
methods: {
shuffle() {
console.log("shuffle");
this.items = _.shuffle(this.items);
},
},
};
</script>
<!--STYLES-->
<style scoped>
.main_container {
width: 400px;
height: 400px;
display: flex;
align-items: center;
justify-content: center;
}
.container {
width: 300px;
height: 300px;
display: flex;
flex-wrap: wrap;
}
.cell {
width: 20%;
height: 20%;
display: flex;
}
.cell-move {
transition: transform 1s;
}
</style>