vue-sortable-list

Vue directive for lists allowing draggable sorting in sync.
2,935 2
Install
npm install vue-sortable-list
Latest Version:0.1.2
License:ISC
Last Updated:Jun 23, 2019
Links: GitHub  ·  npm
Maintainer: traxo

vue-sortable-list

Directive which makes your Vue list draggable.

  • Touch support
  • Handle support

Examples at codesandbox: https://codesandbox.io/s/1yplrk6kw7

Requirements
  • Vue ^2.0
Installation

From npm:
npm i -S vue-sortable-list

Usage

Register the directive:

import VDraggable from 'vue-sortable-list'
Vue.use(VDraggable)

Use v-draggable attribute on any list element (e.g. <ul v-draggable="{value: items}">), and have value reference to your items list in your data object.

Examples

Script
data: () => ({
  items = ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven']
})
HTML

Without handle:

<ul v-draggable="{value: items}">
  <li v-for="item in items" :key="item">{{ item }}</li>
</ul>

With handle:

<ul v-draggable="{value: items, handle: 'handle'}">
  <li v-for="item in items" :key="item">
    <span class="handle">||</span>
    {{ item }}
  </li>
</ul>

With depth:

<div v-draggable="{value: items, depth: 1}">
  <ul>
    <li v-for="item in items" :key="item">{{ item }}</li>
  </ul>
</div>

API

v-draggable={value: items, handle: 'handle', placeholderClass: 'placeholder'}

Props
  • {Array} value - array of list items
  • {String} handle - class used by handle element
  • {String} [placeholderClass = 'v-draggable__placeholder'] - class used by placeholder element
  • {Number} depth - determines how deep is list element nested
Events

start - on drag start
end - on drag end
change - list updated - { from, to }

Related Packages

vue3-sortable

Vue 3 sortable lists

10,440 5
sl-vue-tree

draggable tree vue component

116,055
vue3-sortablejs

A directive for Sortable on Vue 3

41,831 25
sl-vue-tree-next

draggable tree vue component

12,243 13
@eraa-in/xtree

Vue3 supported version of sl-vue-tree. A customizable draggable tree component f...

579

Version History

Version Released License
0.1.2 ISC
0.1.1 ISC
0.1.0 ISC
0.0.2 ISC
0.0.1 ISC