• Stars
    star
    766
  • Rank 59,308 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 8 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A sortable list directive with Vue

Awe-dnd

Makes your elements draggable in Vue.

See Demo: http://hilongjw.github.io/vue-dragging/

Some of goals of this project worth noting include:

  • support desktop and mobile
  • Vue data-driven philosophy
  • support multi comb drag
  • Supports both of Vue 1.0 and Vue 2.0

Requirements

  • Vue: ^1.0.0 or ^2.0.0

Install

From npm:

$ npm install awe-dnd --save

Usage

//main.js

import VueDND from 'awe-dnd'

Vue.use(VueDND)
<!--your.vue-->
<script>
export default {
  data () {
    return {
        colors: [{
            text: "Aquamarine"
        }, {
            text: "Hotpink"
        }, {
            text: "Gold"
        }, {
            text: "Crimson"
        }, {
            text: "Blueviolet"
        }, {
            text: "Lightblue"
        }, {
            text: "Cornflowerblue"
        }, {
            text: "Skyblue"
        }, {
            text: "Burlywood"
        }]
    }
  },
  /* if your need multi drag
  mounted: function() {
      this.colors.forEach((item) => {
          Vue.set(item, 'isComb', false)
      })
  } */
}
</script>

<template>
  <div class="color-list">
      <div
          class="color-item"
          v-for="color in colors" v-dragging="{ item: color, list: colors, group: 'color' }"
          :key="color.text"
      >{{color.text}}</div>
  </div>
</template>

API

v-dragging="{ item: color, list: colors, group: 'color' }"

Arguments:

  • {item} Object
  • {list} Array
  • {group} String
  • {comb} String

group is unique key of dragable list.

comb use for multi drag

Example

<!-- Vue2.0 -->
<div class="color-list">
    <div
        class="color-item"
        v-for="color in colors" v-dragging="{ item: color, list: colors, group: 'color' }"
        :key="color.text"
    >{{color.text}}</div>
</div>

<!-- Vue1.0 -->
<div class="color-list">
    <div
        class="color-item"
        v-for="color in colors" v-dragging="{ item: color, list: colors, group: 'color', key: color.text }"
        track-by="text"
    >{{color.text}}</div>
</div>

Event

<div class="color-list">
    <div
        class="color-item"
        v-for="color in colors" v-dragging="{ item: color, list: colors, group: 'color', otherData: otherData, comb: 'isComb' }"
        :key="color.text"
    >{{color.text}}</div>
</div>
export default {
  mounted () {
    this.$dragging.$on('dragged', ({ value }) => {
      console.log(value.item)
      console.log(value.list)
      console.log(value.otherData)
    })
    this.$dragging.$on('dragend', () => {

    })
  }
}

License

The MIT License

More Repositories

1

vue-lazyload

A Vue.js plugin for lazyload your Image or Component in your application.
JavaScript
7,988
star
2

vue-progressbar

A lightweight progress bar for vue
JavaScript
1,460
star
3

vue-recyclerview

Mastering Large Lists with the vue-recyclerview
JavaScript
1,449
star
4

vue-zhihu-daily

zhihu daily spa with vue 线上演示在这里 ---->
JavaScript
1,287
star
5

vue-datepicker

[Deprecated] calendar and datepicker component with material design for Vue.js
Vue
702
star
6

vue-video

A HTML5 video player component for Vue.js
Vue
328
star
7

vue-ssr-hmr-template

Interesting! Vue2 + Webpack2 + HMR + Server Side Render + Express template see demo->
JavaScript
226
star
8

vue-mobile-qq

一个长得像QQ的demo
Vue
221
star
9

vue-vueRouter-webpack-example

a vue webpack example
CSS
212
star
10

vue-slide

A lightweight slide component for vue
JavaScript
208
star
11

weapp-gold

微信小程序的掘金信息流
JavaScript
169
star
12

Qarticles

A lightweight and high performance JavaScript library for creating physical particles
JavaScript
137
star
13

vue-ssr

Use Vue 2.0 Server Side Rendering with Express
JavaScript
93
star
14

zhihu-beautify

beautify your zhihu
CSS
85
star
15

vue-material-blog

a simple blog make by Vue and Material-design-lite
Vue
65
star
16

safari-reaper-demo

HTML
33
star
17

weex-demo

掘金weex版demo
JavaScript
26
star
18

AweSiteChat

A horrible site danmu project base on Vue.js & Wilddog
Vue
21
star
19

vue-audio

A audio player for vue.js
Vue
16
star
20

cov-xss

xss
Vue
9
star
21

cov_localStorageORM

javascript ORM base on Localstorage
JavaScript
8
star
22

CovBookkeeper

vue+echart+express实现的记账web app
JavaScript
4
star
23

weapp-shop

O2O 电商微信小程序
JavaScript
4
star
24

gold-card

nothing here
JavaScript
3
star
25

vue-recyclerview-example

vue-recyclerview example
JavaScript
3
star
26

hatest

A node API testing tool similar to Supertest, based on Axios.
JavaScript
2
star
27

koa-server-arm

JavaScript
2
star
28

sync-console

realtime remote sync console
JavaScript
2
star
29

want-to-eat

使用vue.js做的一个简单material design风格小web app
JavaScript
2
star
30

sync-console-server

real time remote debug tool server side
JavaScript
2
star
31

vue-lazyload-run

vue-lazyload dev
JavaScript
2
star
32

wazi

amaziUI+ajax+PHP online shop
CSS
1
star
33

v8-RuntimeFunctions-list

V8 RuntimeFunctions list
1
star
34

css-rewrite-webpack-plugin

A Webpack plugin to rewrite CSS assets.
JavaScript
1
star
35

cov-rate-limit

A lightweight Rate limiter middleware for Express and Koa. Use to limit repeated requests to public APIs.
JavaScript
1
star
36

vue-ssr-demo

1
star
37

xss-demo

xss-demo
Vue
1
star