Giter Club home page Giter Club logo

vue-drag-and-drop-list's Introduction

vue-drag-and-drop-list npm

Vue directives that allow you to build sortable lists with the native HTML5 drag & drop API. Supports nested lists for building trees and other fancy structures.

😮 Now support 2.0, see vddl 👏👏

Demo

Not supported VueJS 2.0

Directive interface change

In general, in 2.0 directives have a greatly reduced scope of responsibility: they are now only used for applying low-level direct DOM manipulations. In most cases, you should prefer using Components as the main code-reuse abstraction.

✌️This mean it should be a component. You can view vddl.

Supported browsers

IE9+ and all modern browsers are supported.

Touch devices are not supported, because they do not implement the HTML5 drag & drop standard. However, you can use a shim to make it work on touch devices as well.

Installation

npm install vue-drag-and-drop-list --save

or

yarn add vue-drag-and-drop-list

Usage

import Vue from 'vue';
import vueDragAndDropList from 'vue-drag-and-drop-list';

Vue.use(vueDragAndDropList);

or include as an inline script.

Required CSS styles

Both the dnd-list and it's children require relative positioning, so that the directive can determine the mouse position relative to the list and thus calculate the correct drop position.

ul[dnd-list], ul[dnd-list] > li {
    position: relative;
}

Wiki

you should read the Vue directive doc first.

Development

npm install
npm run watch // rollup watch

npm run build //rollup -c

Run Demo

cd demo

// vue project
npm install
npm run dev // webpack

See all demos source code in 'views/*.vue' file.

Thanks

angular-drag-and-drop-lists

License

MIT

vue-drag-and-drop-list's People

Contributors

alex-fun avatar bailnl avatar hejianxian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-drag-and-drop-list's Issues

I got something wrong.

Hi!
Is there some easier simples?I'm a freshman and I got something wrong which i don't know why.Infect I just copied and pasted your code.Here is my code and debugs
This is my Main.vue .

HTML:

        <div class="panel panel-vue">
            <div class="panel-heading">
                <h3 class="panel-title">List {{listName}}</h3>
            </div>
            <div class="panel-body">
                <ul v-dnd-list :dnd-list="list" :dnd-horizontal-list="false">
                    <li v-dnd-draggable v-for="item in list"
                        :dnd-draggable="item"
                        :dnd-index="$index"
                        :dnd-data="list"
                        dnd-selected="selectedEvent"
                        dnd-effect-allowed="move"
                        dnd-dragstart="handleDragstart"
                        dnd-dragend="handleDragend"
                        dnd-canceled="handleCanceled"
                        v-bind:class="{'selected': selected === item}">
                        {{item.label}}
                    </li>
                    <li class="dndPlaceholder red">Custom placeholder</li>
                </ul>
            </div>
        </div>

SCRIPT:

   import Vue from 'vue';
   import vueDragAndDropList from 'vue-drag-and-drop-list';

   Vue.use(vueDragAndDropList);

   export default {
    name: 'Main',
    data() {
      return  {
        "selected": null,
        "lists": {
          "A": [
            {
              "label": "Item A1",
              "disable": false
            },
            {
              "label": "Item A2"
            },
            {
              "label": "Item A3"
            },
            {
              "label": "Item A4"
            }
          ],
          "B": [
            {
              "label": "Item B1"
            },
            {
              "label": "Item B2"
            },
            {
              "label": "Item B3"
            },
            {
              "label": "Item B4"
            }
          ]
        }
      }
    }
  }

DEBUGS:


screenshot

Update to Vue 2

Hello @hejianxian,
This is an awesome package and I wanted to use this package for one of my upcoming projects. Do you have any plan to upgrade this soon?
Also, if you need any helping hand, I would like to contribute with my little knowledge.

Thanks in advance.

VueJS 2.0

Hi,

I was wondering if you were gonna make it VueJS 2.0 compatible?
Because currently it's not working(Uncaught TypeError: Cannot read property 'el' of undefined).

Thanks and keep up the good work!

  • Wouter

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.