Skip to content

Commit 469c7f4

Browse files
committed
README: add section on using plugins
1 parent 0101101 commit 469c7f4

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,19 @@ You can listen to Sortable events by adding the listeners to the `Sortable` comp
9494
>
9595
```
9696

97-
### Use with a Store
97+
### Using plugins
98+
99+
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:
100+
101+
```typescript
102+
import SortableJs from 'sortablejs';
103+
import { Swap } from 'sortablejs/modular/sortable.core.esm';
104+
SortableJs.mount(new Swap());
105+
106+
import { Sortable } from "sortablejs-vue3";
107+
```
108+
109+
### Use with a store
98110

99111
No changes are necessary to work with Vuex or another store. Just pass `store.state.items` as your list. To modify your data you need to manually listen to the events and calculate the new position with `event.oldIndex` and `event.newIndex` with something like the following:
100112

src/App.vue

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import HelloWorld from "./components/HelloWorld.vue";
1010
Source on <a href="https://github.com/maxleiter/sortablejs-vue3">GitHub</a>
1111
</h2>
1212
<ol class="instructions">
13-
<li>First run <code>yarn add sortablejs-vue3 sortablejs</code></li>
13+
<li>First run
14+
<code>yarn add sortablejs-vue3 <a href="https://github.com/SortableJS/Sortable" target="_blank" rel="noreferrer">sortablejs</a></code>
15+
</li>
1416
<li>
1517
Then add
1618
<pre><code>import { Sortable } from "sortablejs-vue3"</code></pre>
@@ -38,22 +40,17 @@ import HelloWorld from "./components/HelloWorld.vue";
3840
<summary>Props</summary>
3941
<ul>
4042
<li>
41-
<strong><code>options</code></strong
42-
>: An object supporting all SortedJS options. See Sortable on GitHub
43-
<a
44-
href="https://github.com/SortableJS/Sortable#options"
45-
rel="noreferrer"
46-
target="_blank"
47-
>for a full list</a
48-
>.
43+
<strong><code>options</code></strong>: An object supporting all SortedJS options. See Sortable on GitHub
44+
<a href="https://github.com/SortableJS/Sortable#options" rel="noreferrer" target="_blank">for a full list</a>.
45+
</li>
46+
<li>
47+
<strong><code>list</code></strong>: An array-like object of elements to be made draggable.
4948
</li>
5049
<li>
51-
<strong><code>list</code></strong
52-
>: An array-like object of elements to be made draggable.
50+
<strong><code>itemKey</code></strong>: A key to index the elements of the list.
5351
</li>
5452
<li>
55-
<strong><code>itemKey</code></strong
56-
>: A key to index the elements of the list.
53+
<strong><code>tag</code></strong>: The element type to render as. Defaults to <code>div</code>.
5754
</li>
5855
</ul>
5956
</details>
@@ -67,9 +64,7 @@ import HelloWorld from "./components/HelloWorld.vue";
6764
<p>
6865
Made by <a href="https://twitter.com/max_leiter">@Max_Leiter</a> &mdash;
6966
Code for this page is available on
70-
<a
71-
href="https://github.com/MaxLeiter/sortablejs-vue3/blob/main/src/components/HelloWorld.vue"
72-
>
67+
<a href="https://github.com/MaxLeiter/sortablejs-vue3/blob/main/src/components/HelloWorld.vue">
7368
GitHub
7469
</a>
7570
</p>
@@ -171,18 +166,17 @@ import HelloWorld from "./components/HelloWorld.vue";
171166
#app a:after {
172167
content: "";
173168
position: absolute;
174-
width: 100%;
169+
width: 90%;
175170
transform: scaleX(0);
176171
height: 1px;
177172
bottom: 0;
178-
left: 0;
173+
/* offset the 90% */
174+
left: 5%;
179175
background-color: hsl(215, 83%, 67%);
180176
transform-origin: bottom right;
181-
transition: transform 0.15s ease-in-out;
182177
}
183178
184179
#app a:hover:after {
185180
transform: scaleX(1);
186-
transform-origin: bottom left;
187181
}
188182
</style>

0 commit comments

Comments
 (0)