Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Jexordexan/vue-slicksort
A set of vue mixins to turn any list into an animated, touch-friendly, sortable list ✌️
https://github.com/Jexordexan/vue-slicksort
animated dependency drag drop free grid mixin-components sort sortable-elements sortable-helper vue-slicksort
Last synced: 3 months ago
JSON representation
A set of vue mixins to turn any list into an animated, touch-friendly, sortable list ✌️
- Host: GitHub
- URL: https://github.com/Jexordexan/vue-slicksort
- Owner: Jexordexan
- License: other
- Created: 2018-01-15T19:31:04.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2023-11-06T14:21:55.000Z (about 1 year ago)
- Last Synced: 2024-07-20T10:20:50.404Z (4 months ago)
- Topics: animated, dependency, drag, drop, free, grid, mixin-components, sort, sortable-elements, sortable-helper, vue-slicksort
- Language: TypeScript
- Homepage: http://vue-slicksort.netlify.app
- Size: 2.56 MB
- Stars: 1,473
- Watchers: 24
- Forks: 157
- Open Issues: 90
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Vue Slicksort 🖖
![Slicksort logo](/logo/logomark.png)
> A set of component mixins to turn any list into an animated, touch-friendly, sortable list.
> Based on [react-sortable-hoc](https://github.com/clauderic/react-sortable-hoc) by [@clauderic][![npm version](https://img.shields.io/npm/v/vue-slicksort.svg)](https://www.npmjs.com/package/vue-slicksort)
[![npm downloads](https://img.shields.io/npm/dm/vue-slicksort.svg)](https://www.npmjs.com/package/vue-slicksort)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/Jexordexan/vue-slicksort/blob/master/LICENSE)
![gzip size](http://img.badgesize.io/https://npmcdn.com/vue-slicksort?compression=gzip)### Examples available here: [vue-slicksort.netlify.app/](https://vue-slicksort.netlify.app/)
### [中文文档](./doc/zh.md)
## Features
- **`v-model` Compatible** – Make any array editable with the `v-model` standard
- **Mixin Components** – Integrates with your existing components
- **Standalone Components** – Easy to use components for slick lists
- **Drag handle, auto-scrolling, locked axis, events, and more!**
- **Suuuper smooth animations** – Chasing the 60FPS dream 🌈
- **Horizontal lists, vertical lists, or a grid** ↔ ↕ ⤡
- **Touch support** 👌
- **Oh yeah, and it's DEPENDENCY FREE!** 👌## Installation
Using [npm](https://www.npmjs.com/package/vue-slicksort):
```
$ npm install vue-slicksort --save
```Using yarn:
```
$ yarn add vue-slicksort
```Using a CDN:
```html
```
Then, using a module bundler that supports either CommonJS or ES2015 modules, such as [webpack](https://github.com/webpack/webpack):
```js
// Using an ES6 transpiler like Babel
import { ContainerMixin, ElementMixin } from 'vue-slicksort';// Not using an ES6 transpiler
var slicksort = require('vue-slicksort');
var ContainerMixin = slicksort.ContainerMixin;
var ElementMixin = slicksort.ElementMixin;
```If you are loading the package via `` tag:
```html
<script>
var { ContainerMixin, ElementMixin, HandleDirective } = window.VueSlicksort;```
## Usage
Check out the docs: [vue-slicksort.netlify.app](https://vue-slicksort.netlify.app/)
## Why should I use this?
There are already a number of great Drag & Drop libraries out there (for instance, [vuedraggable](https://github.com/SortableJS/Vue.Draggable) is fantastic). If those libraries fit your needs, you should definitely give them a try first. However, most of those libraries rely on the HTML5 Drag & Drop API, which has some severe limitations. For instance, things rapidly become tricky if you need to support touch devices, if you need to lock dragging to an axis, or want to animate the nodes as they're being sorted. Vue Slicksort aims to provide a simple set of component mixins to fill those gaps. If you're looking for a dead-simple, mobile-friendly way to add sortable functionality to your lists, then you're in the right place.
# FAQ
### Upgrade from v1.x
There are a few changes in v2, mainly support for Vue 3 and dragging between groups. Read more about migrating here:
[vue-slicksort.netlify.app/migrating-1x](https://vue-slicksort.netlify.app/migrating-1x)### Upgrade from v0.x
The event names have all changed from camelCase to dash-case to accommodate for inline HTML templates.
### Grid support?
Need to sort items in a grid? We've got you covered! Just set the `axis` prop to `xy`. Grid support is currently limited to a setup where all the cells in the grid have the same width and height, though we're working hard to get variable width support in the near future.
### Item disappearing when sorting / CSS issues
Upon sorting, `vue-slicksort` creates a clone of the element you are sorting (the _sortable-helper_) and appends it to the end of the `appendTo` tag. The original element will still be in-place to preserve its position in the DOM until the end of the drag (with inline-styling to make it invisible). If the _sortable-helper_ gets messed up from a CSS standpoint, consider that maybe your selectors to the draggable item are dependent on a parent element which isn't present anymore (again, since the _sortable-helper_ is at the end of the `appendTo` prop). This can also be a `z-index` issue, for example, when using `vue-slicksort` within a Bootstrap modal, you'll need to increase the `z-index` of the SortableHelper so it is displayed on top of the modal.
### Click events being swallowed
By default, `vue-slicksort` is triggered immediately on `mousedown`. If you'd like to prevent this behaviour, there are a number of strategies readily available. You can use the `distance` prop to set a minimum distance (in pixels) to be dragged before sorting is enabled. You can also use the `pressDelay` prop to add a delay before sorting is enabled. Alternatively, you can also use the [HandleDirective](https://github.com/Jexordexan/vue-slicksort/blob/master/src/HandleDirective.js).
### Scoped styles
If you are using scoped styles on the sortable list, you can use `appendTo` prop.
## Dependencies
Slicksort has no dependencies.
`vue` is the only peerDependency## Reporting Issues
If believe you've found an issue, please [report it](https://github.com/Jexordexan/vue-slicksort/issues) along with any relevant details to reproduce it. The easiest way to do so is to fork this [jsfiddle](https://jsfiddle.net/Jexordexan/1puv2L6c/).
## Asking for help
Please file an issue for personal support requests. Tag them with `question`.
## Contributions
Yes please! Feature requests / pull requests are welcome.
## Thanks
This library is heavily based on [react-sortable-hoc](https://github.com/clauderic/react-sortable-hoc) by Claudéric Demers (@clauderic). A very simple and low overhead implementation of drag and drop that looks and performs great!