Gathering detailed insights and metrics for vuedraggable
Gathering detailed insights and metrics for vuedraggable
Gathering detailed insights and metrics for vuedraggable
Gathering detailed insights and metrics for vuedraggable
vuedraggable-es
draggable component for vue
zhyswan-vuedraggable
draggable component for vue
@marshallswain/vuedraggable
draggable component for vue
form-engine-vue3
```json "dependencies": { "axios": "^0.21.1", "codemirror": "^5.62.2", "core-js": "^3.8.3", "element-plus": "^1.0.2-beta.33", "vue": "3.1.4", "vue-i18n": "^9.1.7", "vuedraggable": "^4.0.3" } "devDependencies": { "@vue/cli-plugin
Vue drag-and-drop component based on Sortable.js
npm install vuedraggable
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
20,185 Stars
521 Commits
2,900 Forks
237 Watching
28 Branches
32 Contributors
Updated on 27 Nov 2024
Minified
Minified + Gzipped
JavaScript (55.36%)
Vue (44.09%)
HTML (0.56%)
Cumulative downloads
Total Downloads
Last day
-3.7%
157,444
Compared to previous day
Last week
-0.4%
775,988
Compared to previous week
Last month
16%
3,346,250
Compared to previous month
Last year
10.7%
35,163,602
Compared to previous year
1
24
Vue component (Vue.js 2.0) or directive (Vue.js 1.0) allowing drag-and-drop and synchronization with view model array.
Based on and offering all features of Sortable.js
https://sortablejs.github.io/Vue.Draggable/
https://david-desmaisons.github.io/draggable-example/
tag
and componentData
propsLooking for backers!
Find this project useful? You can buy me a :coffee: or a :beer:
1yarn add vuedraggable 2 3npm i -S vuedraggable
Beware it is vuedraggable for Vue 2.0 and not vue-draggable which is for version 1.0
1 2<script src="//cdnjs.cloudflare.com/ajax/libs/vue/2.5.2/vue.min.js"></script> 3<!-- CDNJS :: Sortable (https://cdnjs.com/) --> 4<script src="//cdn.jsdelivr.net/npm/sortablejs@1.8.4/Sortable.min.js"></script> 5<!-- CDNJS :: Vue.Draggable (https://cdnjs.com/) --> 6<script src="//cdnjs.cloudflare.com/ajax/libs/Vue.Draggable/2.20.0/vuedraggable.umd.min.js"></script> 7
Use draggable component:
1<draggable v-model="myArray" group="people" @start="drag=true" @end="drag=false"> 2 <div v-for="element in myArray" :key="element.id">{{element.name}}</div> 3</draggable>
.vue file:
1 import draggable from 'vuedraggable' 2 ... 3 export default { 4 components: { 5 draggable, 6 }, 7 ...
transition-group
:1<draggable v-model="myArray"> 2 <transition-group> 3 <div v-for="element in myArray" :key="element.id"> 4 {{element.name}} 5 </div> 6 </transition-group> 7</draggable>
Draggable component should directly wrap the draggable elements, or a transition-component
containing the draggable elements.
1<draggable v-model="myArray" draggable=".item"> 2 <div v-for="element in myArray" :key="element.id" class="item"> 3 {{element.name}} 4 </div> 5 <button slot="footer" @click="addPeople">Add</button> 6</draggable>
1<draggable v-model="myArray" draggable=".item"> 2 <div v-for="element in myArray" :key="element.id" class="item"> 3 {{element.name}} 4 </div> 5 <button slot="header" @click="addPeople">Add</button> 6</draggable>
1<draggable v-model='myList'>
1computed: { 2 myList: { 3 get() { 4 return this.$store.state.myList 5 }, 6 set(value) { 7 this.$store.commit('updateList', value) 8 } 9 } 10}
Type: Array
Required: false
Default: null
Input array to draggable component. Typically same array as referenced by inner element v-for directive.
This is the preferred way to use Vue.draggable as it is compatible with Vuex.
It should not be used directly but only though the v-model
directive:
1<draggable v-model="myArray">
Type: Array
Required: false
Default: null
Alternative to the value
prop, list is an array to be synchronized with drag-and-drop.
The main difference is that list
prop is updated by draggable component using splice method, whereas value
is immutable.
Do not use in conjunction with value prop.
New in version 2.19
Sortable options can be set directly as vue.draggable props since version 2.19.
This means that all sortable option are valid sortable props with the notable exception of all the method starting by "on" as draggable component expose the same API via events.
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:
1<draggable 2 v-model="list" 3 handle=".handle" 4 :group="{ name: 'people', pull: 'clone', put: false }" 5 ghost-class="ghost" 6 :sort="false" 7 @change="log" 8 > 9 <!-- --> 10</draggable>
Type: String
Default: 'div'
HTML node type of the element that draggable component create as outer element for the included slot.
It is also possible to pass the name of vue component as element. In this case, draggable attribute will be passed to the create component.
See also componentData if you need to set props or event to the created component.
Type: Function
Required: false
Default: (original) => { return original;}
Function called on the source component to clone element when clone option is true. The unique argument is the viewModel element to be cloned and the returned value is its cloned version.
By default vue.draggable reuses the viewModel element, so you have to use this hook if you want to clone or deep clone it.
Type: Function
Required: false
Default: null
If not null this function will be called in a similar way as Sortable onMove callback. Returning false will cancel the drag operation.
1function onMoveCallback(evt, originalEvent){ 2 ... 3 // return false; — for cancel 4}
evt object has same property as Sortable onMove event, and 3 additional properties:
draggedContext
: context linked to dragged element
index
: dragged element indexelement
: dragged element underlying view model elementfutureIndex
: potential index of the dragged element if the drop operation is acceptedrelatedContext
: context linked to current drag operation
index
: target element indexelement
: target element view model elementlist
: target listcomponent
: target VueComponentHTML:
1<draggable :list="list" :move="checkMove">
javascript:
1checkMove: function(evt){ 2 return (evt.draggedContext.element.name!=='apple'); 3}
See complete example: Cancel.html, cancel.js
Type: Object
Required: false
Default: null
This props is used to pass additional information to child component declared by tag props.
Value:
props
: props to be passed to the child componentattrs
: attrs to be passed to the child componenton
: events to be subscribe in the child componentExample (using element UI library):
1<draggable tag="el-collapse" :list="list" :component-data="getComponentData()"> 2 <el-collapse-item v-for="e in list" :title="e.title" :name="e.name" :key="e.name"> 3 <div>{{e.description}}</div> 4 </el-collapse-item> 5</draggable>
1methods: { 2 handleChange() { 3 console.log('changed'); 4 }, 5 inputChanged(value) { 6 this.activeNames = value; 7 }, 8 getComponentData() { 9 return { 10 on: { 11 change: this.handleChange, 12 input: this.inputChanged 13 }, 14 attrs:{ 15 wrap: true 16 }, 17 props: { 18 value: this.activeNames 19 } 20 }; 21 } 22 }
Support for Sortable events:
start
, add
, remove
, update
, end
, choose
, unchoose
, sort
, filter
, clone
Events are called whenever onStart, onAdd, onRemove, onUpdate, onEnd, onChoose, onUnchoose, onSort, onClone are fired by Sortable.js with the same argument.
See here for reference
Note that SortableJS OnMove callback is mapped with the move prop
HTML:
1<draggable :list="list" @end="onEnd">
change event
change
event is triggered when list prop is not null and the corresponding array is altered due to drag-and-drop operation.
This event is called with one argument containing one of the following properties:
added
: contains information of an element added to the array
newIndex
: the index of the added elementelement
: the added elementremoved
: contains information of an element removed from to the array
oldIndex
: the index of the element before removeelement
: the removed elementmoved
: contains information of an element moved within the array
newIndex
: the current index of the moved elementoldIndex
: the old index of the moved elementelement
: the moved elementLimitation: neither header or footer slot works in conjunction with transition-group.
Use the header
slot to add none-draggable element inside the vuedraggable component.
Important: it should be used in conjunction with draggable option to tag draggable element.
Note that header slot will always be added before the default slot regardless its position in the template.
Ex:
1<draggable v-model="myArray" draggable=".item"> 2 <div v-for="element in myArray" :key="element.id" class="item"> 3 {{element.name}} 4 </div> 5 <button slot="header" @click="addPeople">Add</button> 6</draggable>
Use the footer
slot to add none-draggable element inside the vuedraggable component.
Important: it should be used in conjunction with draggable option to tag draggable elements.
Note that footer slot will always be added after the default slot regardless its position in the template.
Ex:
1<draggable v-model="myArray" draggable=".item"> 2 <div v-for="element in myArray" :key="element.id" class="item"> 3 {{element.name}} 4 </div> 5 <button slot="footer" @click="addPeople">Add</button> 6</draggable>
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 4/19 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
97 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More