Skip to content

Commit

Permalink
Solution for issue #647
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Desmaisons committed Jun 20, 2019
1 parent 24f4c08 commit ad14a8a
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 9 deletions.
102 changes: 102 additions & 0 deletions example/components/functional.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<template>
<div class="row">
<div class="col-8">
<h3>Draggable</h3>

<draggable
v-model="rows"
tag="v-layout"
class="row wrap fill-height align-center sortable-list"
style="background: grey;"
>
<v-flex
v-for="row in rows"
:key="row.index"
class="sortable"
xs12
my-2
style="background: red"
>

<draggable
:list="row.items"
tag="v-layout"
:group="{ name: 'row' }"
class="row wrap justify-space-around"
>
<v-flex
v-for="item in row.items"
:key="item.title"
xs4
pa-3
class="row"
>
<v-card style="height: 100px;">{{ item.title }}</v-card>
</v-flex>
</draggable>

</v-flex>
</draggable>
</div>

<rawDisplayer
class="col-3"
:value="rows"
title="List"
/>
</div>
</template>

<script>
import draggable from "@/vuedraggable";
import Vue from "vue";
import Vuetify from "vuetify";
import "vuetify/dist/vuetify.min.css";
Vue.use(Vuetify);
export default {
name: "functional",
display: "Functional third party",
order: 17,
components: {
draggable
},
data() {
return {
enabled: true,
rows: [
{
index: 1,
items: [
{
title: "item 1"
}
]
},
{
index: 2,
items: [
{
title: "item 2",
},
{
title: "item 3"
}
]
}
]
};
}
};
</script>
<style scoped>
.buttons {
margin-top: 35px;
}
.ghost {
opacity: 0.5;
background: #c8ebfb;
}
</style>
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"vue-router": "^3.0.2",
"vue-server-renderer": "^2.6.8",
"vue-template-compiler": "^2.6.8",
"vuetify": "^1.5.16",
"vuex": "^3.1.1"
},
"eslintConfig": {
Expand Down
17 changes: 8 additions & 9 deletions src/vuedraggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ const draggableComponent = {
data() {
return {
transitionMode: false,
noneFunctionalComponentMode: false,
init: false
noneFunctionalComponentMode: false
};
},

Expand Down Expand Up @@ -186,7 +185,8 @@ const draggableComponent = {

mounted() {
this.noneFunctionalComponentMode =
this.getTag().toLowerCase() !== this.$el.nodeName.toLowerCase();
this.getTag().toLowerCase() !== this.$el.nodeName.toLowerCase() &&
!this.getIsFunctional();
if (this.noneFunctionalComponentMode && this.transitionMode) {
throw new Error(
`Transition-group inside component is not supported. Please alter tag value or remove transition-group. Current tag value: ${this.getTag()}`
Expand Down Expand Up @@ -251,6 +251,11 @@ const draggableComponent = {
},

methods: {
getIsFunctional() {
const { fnOptions } = this._vnode;
return fnOptions && fnOptions.functional;
},

getTag() {
return this.tag || this.element;
},
Expand All @@ -265,12 +270,6 @@ const draggableComponent = {
},

getChildrenNodes() {
if (!this.init) {
this.noneFunctionalComponentMode =
this.noneFunctionalComponentMode && this.$children.length === 1;
this.init = true;
}

if (this.noneFunctionalComponentMode) {
return this.$children[0].$slots.default;
}
Expand Down

0 comments on commit ad14a8a

Please sign in to comment.