Skip to content

Commit ef3eee6

Browse files
authored
Fix README example to use nextTick, add multiple groups example (#97)
1 parent 201bff6 commit ef3eee6

File tree

9 files changed

+918
-17
lines changed

9 files changed

+918
-17
lines changed

.eslintrc.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require("@rushstack/eslint-patch/modern-module-resolution");
2+
3+
module.exports = {
4+
env: {
5+
node: true,
6+
},
7+
extends: [
8+
"eslint:recommended",
9+
"plugin:vue/vue3-recommended",
10+
"@vue/eslint-config-typescript",
11+
"prettier",
12+
],
13+
parser: "vue-eslint-parser",
14+
parserOptions: {
15+
parser: "@typescript-eslint/parser",
16+
sourceType: "module",
17+
},
18+
rules: {
19+
// override/add rules settings here, such as:
20+
// 'vue/no-unused-vars': 'error'
21+
},
22+
};

README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import { Sortable } from "sortablejs-vue3";
6464
```
6565

6666
4. The `list` and `item-key` props are necessary. The `options` prop is an object that can contain any SortableJS option. You can find a full list of them here: https://github.com/SortableJS/Sortable#options
67-
- The `tag` prop is optional and defaults to `div`. It's the HTML node type for the outer element of the included template/slot.
67+
- The `tag` prop is optional and defaults to `div`. It's the HTML node type for the outer element of the included template/slot.
6868

6969
### Props
7070

@@ -102,8 +102,8 @@ You can listen to Sortable events by adding the listeners to the `Sortable` comp
102102
You need to mount any plugins you want outside of [the default](https://github.com/SortableJS/Sortable#plugins) before importing this library. For example, the below is correct:
103103

104104
```typescript
105-
import SortableJs from 'sortablejs';
106-
import { Swap } from 'sortablejs/modular/sortable.core.esm';
105+
import SortableJs from "sortablejs";
106+
import { Swap } from "sortablejs/modular/sortable.core.esm";
107107
SortableJs.mount(new Swap());
108108

109109
import { Sortable } from "sortablejs-vue3";
@@ -116,14 +116,18 @@ No changes are necessary to work with Vuex or another store. Just pass `store.st
116116
```typescript
117117
const moveItemInArray = <T>(array: T[], from: number, to: number) => {
118118
const item = array.splice(from, 1)[0];
119-
array.splice(to, 0, item);
119+
nextTick(() => array.splice(to, 0, item));
120120
};
121121

122122
onEnd(event) { moveItemInArray(store.state.items, event.oldIndex, event.newIndex) }
123123
```
124124

125125
You may also want to see the SortableJS store documentation [here](https://github.com/SortableJS/Sortable#store).
126126

127+
### Examples
128+
129+
- [./src/examples/WithStore.vue](./src/examples/WithStore.vue) - A simple example with a store
130+
127131
## Development
128132

129133
1. Run `yarn` to install dependencies

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"@types/node": "18.14.2",
4848
"@types/sortablejs": "1.15.0",
4949
"@vitejs/plugin-vue": "4.0.0",
50+
"eslint-config-prettier": "^9.0.0",
5051
"prettier": "2.8.4",
5152
"terser": "5.16.5",
5253
"typescript": "4.9.5",

0 commit comments

Comments
 (0)