Gathering detailed insights and metrics for vue-draggable-plus
Gathering detailed insights and metrics for vue-draggable-plus
Gathering detailed insights and metrics for vue-draggable-plus
Gathering detailed insights and metrics for vue-draggable-plus
clone-vue-draggable-plus
vue3拖拽排序组件,源仓库地址为https://github.com/Alfred-Skyblue/vue-draggable-plus
hsm-vue-component
A draggable and resizable dialog component based on Element Plus
low-code-draggable-plus
vue draggable component, support nest component data modify,vue2.x,vue3.x
form-create-designer
好用的Vue低代码可视化表单设计器,可以通过拖拽的方式快速创建表单,提高开发者对表单的开发效率。
Universal Drag-and-Drop Component Supporting both Vue 3 and Vue 2
npm install vue-draggable-plus
Typescript
Module System
Node Version
NPM Version
99.3
Supply Chain
98.7
Quality
80.8
Maintenance
100
Vulnerability
100
License
Vue (66.55%)
TypeScript (30.61%)
JavaScript (2.84%)
Total Downloads
2,950,773
Last Day
1,605
Last Week
90,597
Last Month
382,085
Last Year
2,515,441
MIT License
3,659 Stars
256 Commits
151 Forks
19 Watchers
5 Branches
25 Contributors
Updated on Jun 23, 2025
Minified
Minified + Gzipped
Latest Version
0.6.0
Package Id
vue-draggable-plus@0.6.0
Unpacked Size
208.25 kB
Size
66.43 kB
File Count
14
NPM Version
10.7.0
Node Version
20.15.0
Published on
Nov 14, 2024
Cumulative downloads
Total Downloads
Last Day
-10.6%
1,605
Compared to previous day
Last Week
-14.4%
90,597
Compared to previous week
Last Month
13.8%
382,085
Compared to previous month
Last Year
486.3%
2,515,441
Compared to previous year
1
1
26
Drag and drop sorting module, support Vue>=v3 or Vue>=2.7
Since the vue3
component of Sortablejs
has not been updated, it has been seriously out of touch with vue3
, so this project was born. This component is based on Sortablejs
, so if you want to know more about Sortablejs
, you can check it out Sortablejs
official website
We have encapsulated a variety of usages for this, you can use components, function, or instructions, there is always one that suits you
In Sortablejs
official Vue
components in the past, the drag-and-drop list is implemented by using the component as a direct child element of the list. When we use some component libraries, if there is no slot for the root element of the list in the component library , it is difficult for us to implement a drag list, vue-draggable-plus perfectly solves this problem, it allows you to use a drag list on any element, we can use the selector of the specified element to get the root element of the list, and then Use the root element of the list as container
of Sortablejs
, for details, refer to specify target container.
1 2npm install vue-draggable-plus 3
1<template> 2 <VueDraggable ref="el" v-model="list"> 3 <div v-for="item in list" :key="item.id"> 4 {{ item.name }} 5 </div> 6 </VueDraggable> 7</template> 8 9<script setup lang="ts"> 10import { ref } from 'vue' 11import { VueDraggable } from 'vue-draggable-plus' 12 13const list = ref([ 14 { 15 name: 'Joao', 16 id: 1 17 }, 18 { 19 name: 'Jean', 20 id: 2 21 }, 22 { 23 name: 'Johanna', 24 id: 3 25 }, 26 { 27 name: 'Juan', 28 id: 4 29 } 30]) 31</script>
1<template> 2 <div ref="el"> 3 <div v-for="item in list" :key="item.id"> 4 {{ item.name }} 5 </div> 6 </div> 7</template> 8 9<script setup lang="ts"> 10import { ref } from 'vue' 11import { useDraggable } from 'vue-draggable-plus' 12 13const el = ref<HTMLElement | null>(null) 14const list = ref([ 15 { 16 name: 'Joao', 17 id: 1 18 }, 19 { 20 name: 'Jean', 21 id: 2 22 }, 23 { 24 name: 'Johanna', 25 id: 3 26 }, 27 { 28 name: 'Juan', 29 id: 4 30 } 31]) 32// The return value is an object, which contains some methods, such as start, destroy, pause, etc. 33const draggable = useDraggable(el, list, { 34 animation: 150, 35 onStart() { 36 console.log('start') 37 }, 38 onUpdate() { 39 console.log('update') 40 } 41}) 42</script>
1<template> 2 <div 3 v-draggable="[ 4 list, 5 { 6 animation: 150, 7 } 8 ]" 9 > 10 <div v-for="item in list" :key="item.id"> 11 {{ item.name }} 12 </div> 13 </div> 14</template> 15 16<script setup lang="ts"> 17import { ref } from 'vue' 18import { vDraggable } from 'vue-draggable-plus' 19const list = ref([ 20 { 21 name: 'Joao', 22 id: 1 23 }, 24 { 25 name: 'Jean', 26 id: 2 27 }, 28 { 29 name: 'Johanna', 30 id: 3 31 }, 32 { 33 name: 'Juan', 34 id: 4 35 } 36]) 37 38function onStart() { 39 console.log('start') 40} 41 42function onUpdate() { 43 console.log('update') 44} 45</script>
All event functions starting with on
can be passed to components using v-on
. For example:
1 2<template> 3 <VueDraggable v-model="list" @start="onStart" @end="onEnd"></VueDraggable> 4</template> 5<script lang="ts" setup> 6import { ref } from "vue"; 7import { VueDraggable } from 'vue-draggable-plus' 8import { SortableEvent } from "sortablejs"; 9 10const list = ref([ 11 { 12 name: 'Joao', 13 id: '1' 14 }, 15 { 16 name: 'Jean', 17 id: '2' 18 }, 19 { 20 name: 'Johanna', 21 id: '3' 22 }, 23 { 24 name: 'Juan', 25 id: '4' 26 } 27]) 28 29function onStart(event: SortableEvent) { 30 console.log('start drag') 31} 32 33function onEnd(event: SortableEvent) { 34 console.log('end drag') 35} 36</script> 37
For information on using Hooks and directives, please refer to the documentation.
Options
inherits all configuration items from Sortablejs
. For details, please see the Sortablejs
official documentation.
1type Easing = 2 | 'steps(int, start | end)' 3 | 'cubic-bezier(n, n, n, n)' 4 | 'linear' 5 | 'ease' 6 | 'ease-in' 7 | 'ease-out' 8 | 'ease-in-out' 9 | 'step-start' 10 | 'step-end' 11 | 'initial' 12 | 'inherit' 13 14type PullResult = ReadonlyArray<string> | boolean | 'clone'; 15type PutResult = ReadonlyArray<string> | boolean; 16 17interface GroupOptions { 18 /** 19 * Group name. 20 */ 21 name: string; 22 /** 23 * The ability to move from the list. Clone - copy the item instead of moving it. 24 */ 25 pull?: PullResult | ((to: Sortable, from: Sortable, dragEl: HTMLElement, event: SortableEvent) => PullResult) | undefined; 26 /** 27 * Whether elements can be added from other lists, or an array of group names from which elements can be obtained. 28 */ 29 put?: PutResult | ((to: Sortable, from: Sortable, dragEl: HTMLElement, event: SortableEvent) => PutResult) | undefined; 30 /** 31 * After moving to another list, the cloned element is restored to its initial position. 32 */ 33 revertClone?: boolean | undefined; 34} 35 36type Group = string | GroupOptions | undefined; 37 38type ScrollFn = (( 39 this: Sortable, 40 offsetX: number, 41 offsetY: number, 42 originalEvent: Event, 43 touchEvt: TouchEvent, 44 hoverTargetEl: HTMLElement, 45 ) => 'continue' | void) | undefined;
Parameter | Description | Type | Default |
---|---|---|---|
animation | Show animation while dragging | Number | 0 |
chosenClass | CSS class name for chosen item | String | 'sortable-chosen' |
delay | Delay in milliseconds before drag starts | Number | 0 |
delayOnTouchOnly | Delay on touch event | Number | 0 |
direction | Dragging direction, 'vertical' or 'horizontal' (default auto detect) | String | - |
disabled | Disable dragging | Boolean | false |
dragClass | CSS class name for dragged item | String | 'sortable-drag' |
draggable | Selector for draggable items within element | String | - |
emptyInsertThreshold | Distance (in pixels) from empty sortable items where dragging element should be inserted. Set to 0 to disable this feature. | Number | 5 |
easing | Animation easing | Easing | - |
fallbackClass | CSS class name for cloned DOM elements when using forceFallback | String | sortable-fallback |
fallbackOnBody | Append cloned DOM element to body element | Boolean | false |
fallbackTolerance | Pixels mouse must move before drag start when using forceFallback | Number | 0 |
filter | Selector for items that should not be draggable | String | - |
forceFallback | Ignore HTML5 drag and drop behavior and force fallback | Boolean | false |
ghostClass | CSS class name for drop placeholder | String | 'sortable-ghost' |
group | Group items to drag between sortable lists. Both lists must have the same group value. Also define whether lists can be dragged out of, cloned, or receive elements from other lists. See TypeScript type definition above for details. | Group | - |
handle | Selector for handle to initiate drag. If not set, the target element's children are used | String | - |
invertSwap | Always use inverted swap zone if set to true | Boolean | false |
invertedSwapThreshold | Inverted swap zone threshold, defaults to swapThreshold value | Number | - |
preventOnFilter | Call event.preventDefault() on filter event | Boolean | true |
removeCloneOnHide | Remove instead of hiding cloned element when not displayed | Boolean | true |
sort | Allow list items to be sorted within container | Boolean | true |
swapThreshold | Swap zone threshold | Number | 1 |
touchStartThreshold | Pixels before cancelling delay touch event | Number | 1 |
setData | Pass a function where the first argument is of type DataTransfer and the second argument is of type HTMLElement | Function | - |
scroll | Enable scrolling | Boolean | HTMLElement |
scrollFn | Custom scroll function | ScrollFn | - |
scrollSensitivity | The distance in pixels the mouse must be to the edge to start scrolling | Number | - |
scrollSpeed | The scrolling speed in ms/px | number | - |
bubbleScroll | Enables automatic scrolling for all parent elements to make it easier to move items | Boolean | true |
onChoose | Triggered when an item is selected | ((event: SortableEvent) => void) | - |
onUnchoose | Triggered when an item is deselected | ((event: SortableEvent) => void) | - |
onStart | Triggered when an item is picked up for drag and drop | ((event: SortableEvent) => void) | - |
onEnd | Triggered when an item is no longer being dragged | ((event: SortableEvent) => void) | - |
onAdd | Triggered when an item is moved from one list to another | ((event: SortableEvent) => void) | - |
onUpdate | Triggered when the order of the items is updated | ((event: SortableEvent) => void) | - |
onSort | Triggered whenever any changes are made to the list | ((event: SortableEvent) => void) | - |
onRemove | Triggered when an item is removed from the list and moved to another | ((event: SortableEvent) => void) | - |
onFilter | Triggered when trying to drag a filtered item | ((event: SortableEvent) => void) | - |
onMove | Triggered while an item is being dragged | ((event: MoveEvent,originalEvent: Event) => void) | - |
onClone | Triggered when an item is cloned | ((event: SortableEvent) => void) | - |
onChange | Triggered when an item is dragged and changes position | ((event: SortableEvent) => void) | - |
No vulnerabilities found.
No security vulnerabilities found.