### Install vuedraggable via npm Source: https://github.com/sortablejs/vue.draggable/blob/master/documentation/Vue.draggable.for.ReadME.md Install the vuedraggable package using npm for use in your project. ```js npm install vuedraggable ``` -------------------------------- ### Install Vue.Draggable via Package Manager Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md Use npm or yarn to add the library to your project. ```bash yarn add vuedraggable npm i -S vuedraggable ``` -------------------------------- ### Install vue.draggable via Bower Source: https://github.com/sortablejs/vue.draggable/blob/master/documentation/Vue.draggable.for.ReadME.md Install the vue.draggable package using Bower for use in your project. ```js Bower install vue.draggable ``` -------------------------------- ### Vue.Draggable Component Data Method Example Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md Provides a JavaScript example for the 'getComponentData' method, showing how to define 'on' event handlers, 'attrs', and 'props' for the child component used with Vue.Draggable. ```javascript methods: { handleChange() { console.log('changed'); }, inputChanged(value) { this.activeNames = value; }, getComponentData() { return { on: { change: this.handleChange, input: this.inputChanged }, attrs:{ wrap: true }, props: { value: this.activeNames } }; } } ``` -------------------------------- ### Vue Component with Sortable.js Options Source: https://context7.com/sortablejs/vue.draggable/llms.txt This example demonstrates how to use the Vue.Draggable component, passing various Sortable.js options as props and defining event handlers for drag-and-drop actions. ```vue ``` -------------------------------- ### Configuring Child Component Data with Vue.Draggable Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md Demonstrates how to use the 'componentData' prop to pass props, attributes, and event listeners to a child component rendered by Vue.Draggable, using the Element UI library as an example. ```html
{{e.description}}
``` -------------------------------- ### Implementing a Custom Move Callback in Vue.Draggable Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md Provides an example of a JavaScript function to be used with the 'move' prop. This function can prevent certain drag operations, such as dragging an element named 'apple'. ```javascript function onMoveCallback(evt, originalEvent){ ... // return false; — for cancel } ``` ```javascript checkMove: function(evt){ return (evt.draggedContext.element.name!=='apple'); } ``` -------------------------------- ### Set Drag Handle with Options Prop Source: https://github.com/sortablejs/vue.draggable/blob/master/documentation/legacy.options.md Use the `options` prop to configure SortableJS features like specifying a drag handle. This example binds the options object to set '.handle' as the drag handle. ```html ``` -------------------------------- ### Create a Basic Draggable List Source: https://context7.com/sortablejs/vue.draggable/llms.txt Implement a sortable list with v-model binding and event handling for drag state. ```vue ``` -------------------------------- ### Include Vue.Draggable via CDN Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md Load Vue, Sortable.js, and Vue.Draggable directly in the browser. ```html ``` -------------------------------- ### options prop Source: https://github.com/sortablejs/vue.draggable/blob/master/documentation/legacy.options.md Configuration prop for initializing the underlying Sortable object. ```APIDOC ## options (prop) ### Description Used to initialize the sortable object. Note that all methods starting with "on" are ignored as the component exposes the same API via events. ### Parameters #### Request Body - **options** (Object) - Optional - Configuration object for SortableJS. See [Sortable options documentation](https://github.com/RubaXa/Sortable#options). ### Request Example ``` -------------------------------- ### Implement Basic Draggable Component Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md Bind a list to the draggable component and register it in the Vue instance. ```html
{{element.name}}
``` ```js import draggable from 'vuedraggable' ... export default { components: { draggable, }, ... ``` -------------------------------- ### Include Vue.Draggable via CDN Source: https://context7.com/sortablejs/vue.draggable/llms.txt Load the required scripts in your HTML file to use the component without a build system. ```html ``` -------------------------------- ### Configuring Vue.Draggable with Sortable Options Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md Shows how to set Sortable.js options like 'handle', 'group', 'ghost-class', and 'sort' directly as props on the Vue.Draggable component. The 'change' event is also logged. ```html ``` -------------------------------- ### Add Footer and Header Slots Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md Include static elements at the beginning or end of the draggable list using slots. ```html
{{element.name}}
``` ```html
{{element.name}}
``` -------------------------------- ### Using v-model with Vue.Draggable Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md Demonstrates the preferred way to bind an array to the draggable component using the v-model directive for Vuex compatibility. ```html ``` ``` -------------------------------- ### Vue.js 1.0 Module Import (ES5) Source: https://github.com/sortablejs/vue.draggable/blob/master/documentation/Vue.draggable.for.ReadME.md Import and use vuedraggable for Vue.js 1.0 projects using ES5 module syntax. ```js // ES5 //For Vue.js 1.0 var Vue = require('vue') Vue.use(require('vuedraggable')) ``` -------------------------------- ### Vue.js 1.0 Module Import (ES6) Source: https://github.com/sortablejs/vue.draggable/blob/master/documentation/Vue.draggable.for.ReadME.md Import and use VueDraggable for Vue.js 1.0 projects using ES6 module syntax. ```js // ES6 //For Vue.js 1.0 only import VueDraggable from 'vuedraggable' import Vue from 'vue' Vue.use(VueDraggable) ``` -------------------------------- ### Migrate dynamic `options` prop to `v-bind` in Vue.draggable Source: https://github.com/sortablejs/vue.draggable/blob/master/documentation/migrate.md When using a function to provide Sortable.js options, migrate from the deprecated `options` prop to `v-bind` for direct prop binding. This ensures options are correctly passed to the Sortable instance. ```html ``` ```html ``` -------------------------------- ### Using the 'move' Prop with Vue.Draggable Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md Illustrates how to bind a JavaScript method to the 'move' prop in the Vue.Draggable component to control drag-and-drop behavior. ```html ``` ``` -------------------------------- ### Integrate Draggable with Vuex Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md Use a computed property with getter and setter to sync the draggable list with a Vuex store. ```html ``` ```javascript computed: { myList: { get() { return this.$store.state.myList }, set(value) { this.$store.commit('updateList', value) } } } ``` -------------------------------- ### Use Draggable with Transition Group Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md Wrap draggable elements in a transition-group for animated reordering. ```html
{{element.name}}
``` -------------------------------- ### Vue.Draggable Component Props Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md Overview of the primary props used to configure the draggable component, including data binding, cloning, and movement logic. ```APIDOC ## Vue.Draggable Props ### Description Configuration props for the Vue.Draggable component to handle data synchronization and drag-and-drop behavior. ### Parameters #### Props - **value** (Array) - Optional - Input array for the component, compatible with Vuex. Use with v-model. - **list** (Array) - Optional - Alternative to value; synchronized via splice. Do not use with value. - **tag** (String) - Optional - HTML node type or component name for the outer element. Default: 'div'. - **clone** (Function) - Optional - Function to clone elements when clone option is true. Default: (original) => { return original;}. - **move** (Function) - Optional - Callback function to validate drag operations. Return false to cancel. - **componentData** (Object) - Optional - Object to pass props, attrs, and events to the child component defined by the tag prop. ``` -------------------------------- ### Custom Clone Function Source: https://context7.com/sortablejs/vue.draggable/llms.txt Uses the :clone prop to provide a function that transforms data objects during the drag-and-drop process. ```vue ``` -------------------------------- ### Clone Elements Between Lists Source: https://context7.com/sortablejs/vue.draggable/llms.txt Configures a source list to clone items into a target list by setting the pull property to 'clone' and disabling put on the source. ```vue ``` -------------------------------- ### Vue.Draggable Events Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md Overview of supported Sortable.js events and the custom change event triggered by Vue.Draggable. ```APIDOC ## Vue.Draggable Events ### Description Vue.Draggable supports standard Sortable.js events and provides a custom 'change' event for tracking array modifications. ### Events - **Sortable Events**: start, add, remove, update, end, choose, unchoose, sort, filter, clone. - **change**: Triggered when the list prop is altered due to a drag-and-drop operation. ### Change Event Payload - **added** (object) - Information about an added element: newIndex, element. - **removed** (object) - Information about a removed element: oldIndex, element. - **moved** (object) - Information about a moved element: newIndex, oldIndex, element. ``` -------------------------------- ### Drag Handle Source: https://context7.com/sortablejs/vue.draggable/llms.txt Restricts drag initiation to elements matching the CSS selector provided in the handle prop. ```vue ``` -------------------------------- ### Watching ViewModel Collection for Updates Source: https://github.com/sortablejs/vue.draggable/blob/master/documentation/Vue.draggable.for.ReadME.md Since Sortable.js hooks like onStart, onUpdate, onAdd, and onRemove are used internally by v-dragable-for, they cannot be directly used. To listen for re-order events, watch the underlying view model collection. ```js watch: { 'list1': function () { console.log('Collection updated!'); }, } ``` -------------------------------- ### Integrate Vue.Draggable with Vuex Source: https://context7.com/sortablejs/vue.draggable/llms.txt Use computed properties with getters and setters to bind the draggable list to Vuex state. ```vue ``` -------------------------------- ### Vue Draggable with Transition Animations Source: https://context7.com/sortablejs/vue.draggable/llms.txt Integrates Vue.Draggable with Vue's TransitionGroup for animated drag-and-drop operations. Ensure Vue's transition-group and CSS transitions are correctly configured for smooth animations. ```vue ``` -------------------------------- ### Control Dragging with Move Callback Source: https://context7.com/sortablejs/vue.draggable/llms.txt Define a move function to conditionally allow or block drag operations based on the dragged element's context. ```vue ``` -------------------------------- ### Implement Header and Footer Slots in Vue.Draggable Source: https://context7.com/sortablejs/vue.draggable/llms.txt Use the slot attribute to define non-draggable elements that persist at the beginning or end of the draggable list. ```vue ``` -------------------------------- ### Enable Drag-and-Drop Between Two Lists Source: https://context7.com/sortablejs/vue.draggable/llms.txt Assign the same group name to multiple draggable components to allow items to be moved between them. ```vue ``` -------------------------------- ### Vue.Draggable Slots Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md Usage of header and footer slots for adding non-draggable elements within the component. ```APIDOC ## Vue.Draggable Slots ### Description Use header and footer slots to insert non-draggable elements into the component. These slots must be used in conjunction with the 'draggable' option to specify which elements are draggable. ### Slots - **header**: Added before the default slot. - **footer**: Added after the default slot. ### Usage Example
{{element.name}}
``` -------------------------------- ### Draggable Table Rows with Vue.Draggable Source: https://context7.com/sortablejs/vue.draggable/llms.txt Demonstrates how to make table rows sortable using Vue.Draggable. The 'tag' prop is set to 'tbody' to ensure the draggable component renders as a table body element. ```vue ``` -------------------------------- ### Migrate `element` prop to `tag` in Vue.draggable Source: https://github.com/sortablejs/vue.draggable/blob/master/documentation/migrate.md Use the `tag` prop instead of the deprecated `element` prop to specify the HTML element for the draggable list. This aligns with common conventions. ```html ``` ```html ``` -------------------------------- ### Vue.js 1.0 v-dragable-for Directive Usage Source: https://github.com/sortablejs/vue.draggable/blob/master/documentation/Vue.draggable.for.ReadME.md Use the v-dragable-for directive similarly to v-for, passing optional parameters via the 'options' attribute. The options can be a JSON string or a JavaScript object. This directive only works with arrays. ```html

{{element.name}}

``` -------------------------------- ### Nested Draggable Lists Component Source: https://context7.com/sortablejs/vue.draggable/llms.txt A recursive Vue component for creating nested draggable lists. It uses the 'group' option to enable dragging between lists and requires a parent component to provide the initial data structure. ```vue ``` -------------------------------- ### Vue.Draggable End Event Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md Use the @end event to trigger a method when a drag-and-drop operation concludes. This is useful for updating data or performing actions after an item has been moved. ```html ``` -------------------------------- ### Migrate `options` prop to direct binding in Vue.draggable Source: https://github.com/sortablejs/vue.draggable/blob/master/documentation/migrate.md Pass Sortable.js options directly as props to the Vue.draggable component, replacing the deprecated `options` prop. This utilizes a transparent wrapper for passing props to the Sortable instance. ```html ``` ```html ``` -------------------------------- ### Integrate Vue.Draggable with Element UI Source: https://context7.com/sortablejs/vue.draggable/llms.txt Utilize the tag and componentData props to wrap draggable items within third-party UI components like Element UI's collapse. ```vue ``` -------------------------------- ### Parent Component for Nested Draggable Lists Source: https://context7.com/sortablejs/vue.draggable/llms.txt This component utilizes the 'nested-draggable.vue' to display a hierarchical list structure. It initializes the data with a sample nested array and passes it to the nested-draggable component. ```vue ``` -------------------------------- ### TypeScript Type Definitions for MoveEvent Source: https://context7.com/sortablejs/vue.draggable/llms.txt Provides TypeScript type definitions for the `MoveEvent` object, which is passed to event handlers like `checkMove`. This enables type-safe development when working with drag-and-drop events. ```typescript import draggable from 'vuedraggable' // Type definitions available: interface DraggedContext { index: number futureIndex: number element: T } interface DropContext { index: number component: Vue element: T } interface Rectangle { top: number right: number bottom: number left: number width: number height: number } interface MoveEvent { originalEvent: DragEvent dragged: Element draggedContext: DraggedContext draggedRect: Rectangle related: Element relatedContext: DropContext relatedRect: Rectangle from: Element to: Element willInsertAfter: boolean isTrusted: boolean } // Usage in component export default { components: { draggable }, methods: { checkMove(evt: MoveEvent): boolean { return evt.draggedContext.element.canDrag } } } ``` -------------------------------- ### Vue.Draggable Footer Slot Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md The 'footer' slot allows you to add non-draggable elements after the list items. Similar to the header slot, use the 'draggable' option to specify draggable elements. ```html
{{element.name}}
``` -------------------------------- ### Vue.Draggable Change Event Source: https://github.com/sortablejs/vue.draggable/blob/master/README.md The 'change' event is triggered when the list prop is altered due to drag-and-drop. It provides details about added, removed, or moved elements within the list. ```html
{{element.name}}
``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.