![](https://github.com/Vivify-Ideas/vue-draggable/raw/HEAD/./vue-draggable.png)
![MIT License](https://img.shields.io/github/license/Vivify-Ideas/vue-draggable.svg)
Description
Vue Drag and Drop library without any dependency.
Native HTML5 drag and drop implementation made for Vue.
Examples 🎪
Installation
npm install vue-draggable
<!-- or -->
yarn add vue-draggable
Setup
import Vue from 'vue'
import VueDraggable from 'vue-draggable'
Vue.use(VueDraggable)
TypeScript
Included TypeScript definitions.
Browser Compatibility
Polyfills for IE9+ support are included in the repo.
If you need to support IE9 in your applications, import the polyfills:
import 'vue-draggable/polyfills'
Usage
In the template, use the v-drag-and-drop
directive:
HTML
<div v-drag-and-drop:options="options">
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<ul>
<li>Item 4</li>
<li>Item 5</li>
<li>Item 6</li>
</ul>
</div>
Options
Directive v-drag-and-drop
available options
{
dropzoneSelector: 'ul',
draggableSelector: 'li',
handlerSelector: null,
reactivityEnabled: true,
multipleDropzonesItemsDraggingEnabled: true,
showDropzoneAreas: true,
onDrop: function(event) {},
onDragstart: function(event) {},
onDragend: function(event) {}
}
Dropzone events (added, removed, reordered)
<div v-drag-and-drop:options="options">
<ul
@added="added"
@removed="removed"
@reordered="reordered"
>
<li data-id="1">Item 1</li>
<li data-id="2">Item 2</li>
<li data-id="3">Item 3</li>
</ul>
</div>
These three custom events have additional ids
and index
params.
Ids is an array of defined data-id
attributes and index
represents
drop intersection. For more info check out example
Event Params for onDrop
, onDragstart
, onDragend
callbacks
{
nativeEvent: {},
items: [],
owner: null,
droptarget: null
stop: () => {}
}
Contributors 🎖
LICENCE MIT - Created by Nikola Spalevic (nikolaspalevic@gmail.com)