Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
vue-draggable
Advanced tools
Vue Drag and Drop library without any dependency.
Native HTML5 drag and drop implementation made for Vue.
npm install vue-draggable
<!-- or -->
yarn add vue-draggable
import Vue from 'vue'
import VueDraggable from 'vue-draggable'
Vue.use(VueDraggable)
import { VueDraggableDirective } from 'vue-draggable'
export default {
directives: {
dragAndDrop: VueDraggableDirective
}
}
In the template, use the v-drag-and-drop
directive:
<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>
v-drag-and-drop
available options{
dropzoneSelector: 'ul',
draggableSelector: 'li',
handlerSelector: null,
reactivityEnabled: true,
multipleDropzonesItemsDraggingEnabled: true,
showDropzoneAreas: true,
onDrop: function(event) {},
onDragstart: function(event) {},
onDragenter: function(event) {},
onDragover: function(event) {},
onDragend: function(event) {}
}
<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
There is available VueDraggableGroup
component so you don't need to write your own model
manipulation logic. However, usage of this component is optional. Use only with Vue v2.6+.
You can pass to component optional itemsKey
prop if you want to change items collection
property name. By default it's items
.
<div v-drag-and-drop:options="options">
<!-- optional renderless component -->
<vue-draggable-group
v-for="group in groups"
v-model="group.items"
:groups="groups"
:key="group.id"
:data-id="group.id"
@change="onGroupsChange"
>
<ul>
<li
v-for="item in group.items"
:key="item.id"
:data-id="item.id"
>
<label v-text="item.name"></label>
</li>
</ul>
</vue-draggable-group>
</div>
onDrop
, onDragstart
, onDragenter
, onDragover
, onDragend
callbacks{
nativeEvent: {}, // native js event
items: [], // list of selected draggable elements
owner: null, // old dropzone element
droptarget: null // new dropzone element,
stop: () => {} // Stop D&D (available only for callbacks `onDragstart` and `onDragend`)
}
Included TypeScript definitions.
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'
nikolasp | tiagocsilva | piboistudios | swaroopjo | figurluk |
LICENCE MIT - Created by Nikola Spalevic (nikolaspalevic@gmail.com)
FAQs
Vue drag and drop library without any dependency
We found that vue-draggable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.