vue-draggable

WebJar for vue-draggable

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

vue-draggable
Last Version

Last Version

2.0.6
Release Date

Release Date

Type

Type

jar
Description

Description

vue-draggable
WebJar for vue-draggable
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/Vivify-Ideas/vue-draggable

Download vue-draggable

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/vue-draggable/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>vue-draggable</artifactId>
    <version>2.0.6</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/vue-draggable/
implementation 'org.webjars.npm:vue-draggable:2.0.6'
// https://jarcasting.com/artifacts/org.webjars.npm/vue-draggable/
implementation ("org.webjars.npm:vue-draggable:2.0.6")
'org.webjars.npm:vue-draggable:jar:2.0.6'
<dependency org="org.webjars.npm" name="vue-draggable" rev="2.0.6">
  <artifact name="vue-draggable" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='vue-draggable', version='2.0.6')
)
libraryDependencies += "org.webjars.npm" % "vue-draggable" % "2.0.6"
[org.webjars.npm/vue-draggable "2.0.6"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

npm version vue2 GitHub open issues npm download MIT License

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

Setup plugin

import Vue from 'vue'
import VueDraggable from 'vue-draggable'

Vue.use(VueDraggable)

Setup directive locally

import { VueDraggableDirective } from 'vue-draggable'

export default {
  directives: {
    dragAndDrop: VueDraggableDirective
  }
}

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) {},
  onDragenter: function(event) {},
  onDragover: 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

Reactivity handling and renderless component

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>

Event Params for 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`)
}

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'

Contributors ๐ŸŽ–

nikolasp tiagocsilva piboistudios swaroopjo figurluk
nikolasp tiagocsilva piboistudios swaroopjo figurluk

LICENCE MIT - Created by Nikola Spalevic ([email protected])

org.webjars.npm

Vivify Ideas

Web & Mobile development company

Versions

Version
2.0.6