Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Sortable.ghost for fallback mode and document non-fallback :set-data prop #1249

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Find this project useful? You can buy me a :coffee: or a :beer:

## Installation

### With npm or yarn
### With npm or yarn

```bash
yarn add vuedraggable
Expand All @@ -66,7 +66,7 @@ npm i -S vuedraggable

**Beware it is vuedraggable for Vue 2.0 and not vue-draggable which is for version 1.0**

### with direct link
### with direct link
```html

<script src="//cdnjs.cloudflare.com/ajax/libs/vue/2.5.2/vue.min.js"></script>
Expand Down Expand Up @@ -137,7 +137,7 @@ Draggable component should directly wrap the draggable elements, or a `transitio

```html
<draggable v-model='myList'>
```
```

```javascript
computed: {
Expand Down Expand Up @@ -184,20 +184,42 @@ This means that all [sortable option](https://github.com/RubaXa/Sortable#options

kebab-case propery are supported: for example `ghost-class` props will be converted to `ghostClass` sortable option.

Example setting handle, sortable and a group option:
Example setting handle, sortable, setData, and a group option:
```HTML
<draggable
v-model="list"
handle=".handle"
:group="{ name: 'people', pull: 'clone', put: false }"
ghost-class="ghost"
:sort="false"
:set-data="overrideGhostImage"
@change="log"
>
<!-- -->
</draggable>
```

Example accessing the `ghost` element in fallback mode:
```HTML
<draggable
v-model="list"
ref="draggable"
:force-fallback="true"
@start="dragStart"
@change="log"
>
<!-- -->
</draggable>
```

```javascript
methods: {
dragStart(): {
this.$refs.draggable.ghost.innerText = "I'm being dragged!"
}
}
```

#### tag
Type: `String`<br>
Default: `'div'`
Expand Down Expand Up @@ -359,22 +381,22 @@ Ex:
</draggable>
```
### Gotchas

- Vue.draggable children should always map the list or value prop using a v-for directive
* You may use [header](https://github.com/SortableJS/Vue.Draggable#header) and [footer](https://github.com/SortableJS/Vue.Draggable#footer) slot to by-pass this limitation.

- Children elements inside v-for should be keyed as any element in Vue.js. Be carefull to provide revelant key values in particular:
* typically providing array index as keys won't work as key should be linked to the items content
* cloned elements should provide updated keys, it is doable using the [clone props](#clone) for example


### Example
### Example
* [Clone](https://sortablejs.github.io/Vue.Draggable/#/custom-clone)
* [Handle](https://sortablejs.github.io/Vue.Draggable/#/handle)
* [Transition](https://sortablejs.github.io/Vue.Draggable/#/transition-example-2)
* [Nested](https://sortablejs.github.io/Vue.Draggable/#/nested-example)
* [Table](https://sortablejs.github.io/Vue.Draggable/#/table-example)

### Full demo example

[draggable-example](https://github.com/David-Desmaisons/draggable-example)
Expand Down
4 changes: 4 additions & 0 deletions src/vuedraggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ const draggableComponent = {

realList() {
return this.list ? this.list : this.value;
},

ghost() {
return Sortable.ghost
}
},

Expand Down