All Projects → gilnd → vue3-smooth-dnd

gilnd / vue3-smooth-dnd

Licence: MIT license
Vue3 wrapper components for smooth-dnd

Programming Languages

Vue
7211 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to vue3-smooth-dnd

Muuri
Infinite responsive, sortable, filterable and draggable layouts
Stars: ✭ 9,797 (+10548.91%)
Mutual labels:  dnd, drag-and-drop, draggable
dflex
The sophisticated Drag and Drop library you've been waiting for 🥳
Stars: ✭ 806 (+776.09%)
Mutual labels:  dnd, drag-and-drop, draggable
react-native-dnd-board
A drag and drop Kanban board for React Native.
Stars: ✭ 41 (-55.43%)
Mutual labels:  dnd, drag-and-drop, draggable
Smooth Dnd
drag and drop library for javascript
Stars: ✭ 408 (+343.48%)
Mutual labels:  dnd, drag-and-drop, draggable
React Dragtastic
A simple drag and drop library for React which uses the more stable mouseDown/mouseUp event pattern instead of the problematic HTML5 drag and drop API
Stars: ✭ 181 (+96.74%)
Mutual labels:  dnd, drag-and-drop, draggable
vite-vue3-lowcode
vue3.x + vite2.x + vant + element-plus H5移动端低代码平台 lowcode 可视化拖拽 可视化编辑器 visual editor 类似易企秀的H5制作、建站工具、可视化搭建工具
Stars: ✭ 1,309 (+1322.83%)
Mutual labels:  drag-and-drop, draggable, vue3
Ngx Smooth Dnd
angular wrapper for smooth-dnd
Stars: ✭ 152 (+65.22%)
Mutual labels:  dnd, drag-and-drop, draggable
react-dnd-treeview
A draggable / droppable React-based treeview component. You can use render props to create each node freely.
Stars: ✭ 207 (+125%)
Mutual labels:  dnd, drag-and-drop
Vddl
🦄 Vue components for modifying lists with the HTML5 drag & drop API.
Stars: ✭ 407 (+342.39%)
Mutual labels:  dnd, drag-and-drop
React Beautiful Dnd
Beautiful and accessible drag and drop for lists with React
Stars: ✭ 25,810 (+27954.35%)
Mutual labels:  dnd, drag-and-drop
React Movable
🔀 Drag and drop for your React lists and tables. Accessible. Tiny.
Stars: ✭ 1,064 (+1056.52%)
Mutual labels:  dnd, drag-and-drop
Draggable
The JavaScript Drag & Drop library your grandparents warned you about.
Stars: ✭ 15,671 (+16933.7%)
Mutual labels:  drag-and-drop, draggable
Bcx Aurelia Dnd
Aurelia Drag and Drop.
Stars: ✭ 20 (-78.26%)
Mutual labels:  dnd, drag-and-drop
Angular Skyhook
An implementation of react-dnd for Angular.
Stars: ✭ 146 (+58.7%)
Mutual labels:  dnd, drag-and-drop
slate-react-dnd-plugin
No description or website provided.
Stars: ✭ 35 (-61.96%)
Mutual labels:  dnd, drag-and-drop
dnd
Beautiful and accessible drag and drop for lists with React.
Stars: ✭ 271 (+194.57%)
Mutual labels:  dnd, drag-and-drop
Easy Dnd
A drag and drop implementation for Vue.js 2 https://codesandbox.io/s/easy-dnd-demo-9mbij https://codesandbox.io/s/easy-dnd-demo-2-xnqbz
Stars: ✭ 202 (+119.57%)
Mutual labels:  dnd, drag-and-drop
ng2-gridstack
A gridstack component for Angular2+
Stars: ✭ 12 (-86.96%)
Mutual labels:  drag-and-drop, draggable
React Dragline
🐼Guide lines and magnetic adsorption to better align draggable elements in React.
Stars: ✭ 134 (+45.65%)
Mutual labels:  drag-and-drop, draggable
Angular Grid Layout
Responsive grid with draggable and resizable items for Angular applications.
Stars: ✭ 163 (+77.17%)
Mutual labels:  drag-and-drop, draggable

vue3-smooth-dnd

Vue 3 Wrapper of smooth-dnd library.
Live demo

NOTE: This is a Vue 3 wrapper over smooth-dnd library. It's a fork of the already done vue2 wrapper done by the original author of the library.

All the documentation for the Vue 2 version works with this package version too!

Install

yarn add vue3-smooth-dnd

Usage

<template>
  <div>
    <span>Studio Ghibli Tier List</span>
    <Container orientation="vertical" @drop="onDrop">            
      <Draggable v-for="(item, i) in items" :key="item.id">
        <div>
           {{i + 1}} -> {{item.data}}
        </div>
      </Draggable>
    </Container>
  </div>
</template>

<script>
import { Container, Draggable } from "vue3-smooth-dnd";
export default {
  name: "app",
  components: { Container, Draggable },
  data() {
    return {
      items: [
        { id: 1, data: "Princess Mononoke" },
        { id: 2, data: "Spirited Away" },
        { id: 3, data: "My Neighbor Totoro" },
        { id: 4, data: "Howl's Moving Castle" }
      ]
    };
  },
  methods: {  
    onDrop(dropResult){
      this.items = this.applyDrag(this.items, dropResult);
    },
    applyDrag(arr, dragResult){
      const { removedIndex, addedIndex, payload } = dragResult;

      if (removedIndex === null && addedIndex === null) return arr;
      const result = [...arr];
      let itemToAdd = payload;
      
      if (removedIndex !== null) {
        itemToAdd = result.splice(removedIndex, 1)[0];
      }
      if (addedIndex !== null) {
        result.splice(addedIndex, 0, itemToAdd);
      }
      return result;
    }
  }
}
</script>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].