I've been attempting to integrate vuedraggable
with Vuetify Cards, but I'm facing an issue where the drag and drop functionality doesn't seem to work when the cards are in a single row. Interestingly, it works perfectly fine when they are displayed in a column layout.
To see a working example, you can visit this CodeSandbox link.
In the Parent.vue
file, if I remove the
<v-layout> </v-layout>
wrapping around the <HelloWorld />
component, the cards automatically switch to a column layout and the drag and drop feature starts functioning as expected.
This is the code snippet for my HelloWorld component:
<template>
<v-flex xs4>
<v-card class="mx-4">
<v-img :src="src"></v-img>
<v-card-title primary-title>
<div>{{title}}</div>
</v-card-title>
</v-card>
</v-flex>
</template>
<script>
export default {
name: "HelloWorld",
props: {
title: String,
src: String,
id: Number
},
data() {
return {};
}
};
</script>
This is my Parent component implementation:
<template>
<v-container>
<v-layout class="mt-5 align-center justify-center row fill-height">
<h2>Parent Component</h2>
</v-layout>
<draggable v-model="draggableCards">
<v-layout>
<template v-for="(tech,i) in getCardArray">
<HelloWorld :src="tech.src" :title="tech.title" :key="i"/>
</template>
</v-layout>
</draggable>
</v-container>
</template>
<script>
import { mapGetters, mapMutations } from "vuex";
import HelloWorld from "./HelloWorld";
import draggable from "vuedraggable";
export default {
components: {
draggable,
HelloWorld
},
computed: {
...mapGetters({
getCardArray: "getCardArray"
}),
draggableCards: {
get() {
return this.$store.state.cardArray;
},
set(val) {
this.$store.commit("setCardArray", val);
}
}
},
methods: {
...mapMutations({
setCardArray: "setCardArray"
})
}
};
</script>
If anyone can provide assistance in resolving this issue, I would greatly appreciate it. Thank you.