vue-dragula

:ok_hand: Drag and drop so simple it hurts http://astray-git.github.io/vue-dragula

  • Owner: Astray-git/vue-dragula
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    2
      Compare:

Github stars Tracking Chart

vue-dragula

:ok_hand: Drag and drop so simple it hurts

Vue wrapper for [dragula][1].

Install

CommonJS

  • Available through npm as vue-dragula.

    npm install vue-dragula
    
    var Vue = require('vue');
    var VueDragula = require('vue-dragula');
    
    Vue.use(VueDragula);
    

Direct include

  • You can also directly include it with a <script> tag when you have Vue and dragula already included globally. It will automatically install itself.

Usage

template:

<div class="wrapper">
  <div class="container" v-dragula="colOne" bag="first-bag">
    <!-- with click -->
    <div v-for="text in colOne" @click="onClick">{{text}} [click me]</div>
  </div>
  <div class="container" v-dragula="colTwo" bag="first-bag">
    <div v-for="text in colTwo">{{text}}</div>
  </div>
</div>

NOTE Vuejs 2.x

To make sure a correct update for DOM element order, we must provide a key for v-for directive inside a dragula container. https://vuejs.org/v2/guide/list.html#key
With v-for="item in list", we need :key="item.id" for object items, :key="item" for plain string.

APIs

You can access them from Vue.vueDragula

options(name, options)

Set dragula options, refer to: https://github.com/bevacqua/dragula#optionscontainers

...
new Vue({
  ...
  created: function () {
    Vue.vueDragula.options('my-bag', {
      direction: 'vertical'
    })
  }
})

find(name)

Returns the bag for a drake instance. Contains the following properties:

  • name the name that identifies the bag
  • drake the raw drake instance

Events

For drake events, refer to: https://github.com/bevacqua/dragula#drakeon-events

...
new Vue({
  ready: function () {
    Vue.vueDragula.eventBus.$on('drop', function (args) {
      console.log('drop: ' + args[0])
    })
  }
})

Special Events for vue-dragula, Event Name, Listener Arguments, Event Description, :-------------:, :-------------:, -----, dropModel, bagName, el, target, source, dropIndex, model was synced, dropIndex exposed, removeModel, bagName, el, container, removeIndex, model was synced, removeIndex exposed, [1]: https://github.com/bevacqua/dragula

Main metrics

Overview
Name With OwnerAstray-git/vue-dragula
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 5)
Platform
License:MIT License
所有者活动
Created At2016-04-26 07:19:15
Pushed At2021-03-24 10:56:30
Last Commit At2020-10-14 11:17:27
Release Count10
Last Release Name2.0.0-alpha.1 (Posted on )
First Release Name0.0.2 (Posted on )
用户参与
Stargazers Count359
Watchers Count8
Fork Count69
Commits Count49
Has Issues Enabled
Issues Count35
Issue Open Count18
Pull Requests Count8
Pull Requests Open Count3
Pull Requests Close Count5
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private