Skip to content

Commit e9f42a7

Browse files
committed
Merge branch 'fix-drop-outside'
2 parents aea1949 + c8fe13f commit e9f42a7

File tree

5 files changed

+57
-27
lines changed

5 files changed

+57
-27
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [v0.1.2] - 2022-11-28
4+
5+
### Fixes
6+
7+
- fix: Dropping items outside of another item wouldn't trigger an update
8+
39
## [v0.1.1] - 2022-08-21
410

511
### Fixes

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-draggable-list",
33
"description": "vue draggable list",
4-
"version": "0.1.1",
4+
"version": "0.1.2",
55
"type": "module",
66
"license": "GPL-3.0",
77
"author": {
@@ -63,4 +63,4 @@
6363
"vue-eslint-parser": "^9.0.3",
6464
"vue-tsc": "^0.40.1"
6565
}
66-
}
66+
}

src/App.vue

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,48 @@
1-
<script setup lang="ts">
2-
// This starter template is using Vue 3 <script setup> SFCs
3-
// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup
1+
<script lang="ts" setup>
2+
import { reactive } from "vue";
3+
import DraggableList from "./components/DraggableList.vue";
4+
5+
const testArray = reactive([
6+
{
7+
id: 1,
8+
name: "Bob"
9+
},
10+
{
11+
id: 2,
12+
name: "Alice"
13+
},
14+
{
15+
id: 3,
16+
name: "Lisa"
17+
}
18+
]);
19+
20+
const onStart = (...args) => {
21+
console.log("On start", args);
22+
};
23+
24+
const onEnd = (...args) => {
25+
console.log("On end", args);
26+
};
27+
28+
const onUpdate = (...args) => {
29+
console.log("On update", args);
30+
};
431
</script>
532

633
<template>
7-
<div>
8-
<a href="https://vitejs.dev" target="_blank">Vite</a>
9-
<a href="https://vuejs.org/" target="_blank">Vue</a>
10-
</div>
34+
<h1>Example</h1>
35+
<DraggableList
36+
item-key="id"
37+
v-model:list="testArray"
38+
@start="onStart"
39+
@end="onEnd"
40+
@update="onUpdate"
41+
>
42+
<template #item="{ element }">
43+
<h2>{{ element.id }} - {{ element.name }}</h2>
44+
</template>
45+
</DraggableList>
1146
</template>
1247

13-
<style scoped>
14-
.logo {
15-
height: 6em;
16-
padding: 1.5em;
17-
will-change: filter;
18-
}
19-
.logo:hover {
20-
filter: drop-shadow(0 0 2em #646cffaa);
21-
}
22-
.logo.vue:hover {
23-
filter: drop-shadow(0 0 2em #42b883aa);
24-
}
25-
</style>
48+
<style scoped></style>

src/components/DraggableList.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ const onDragOver = (itemIndex: number, event: DragEvent, push = false) => {
145145
const onDragEnd = () => {
146146
// Emits the end event to parent component, indicating that dragging has ended
147147
emit("end");
148-
};
149-
// Gets called when an element is dropped on another element
150-
const onDrop = () => {
148+
151149
// Emits the update event to parent component, indicating that the order is now done and ordering/moving is done
152150
if (!window.draggingItem) return;
153151
const { itemIndex, itemListUuid, initialItemIndex, initialItemListUuid } =
@@ -164,6 +162,9 @@ const onDrop = () => {
164162
delete window.draggingItem;
165163
};
166164
165+
// Gets called when an element is dropped on another element, currently not used
166+
const onDrop = () => {};
167+
167168
// Function that gets called for each item and returns attributes
168169
const convertAttributes = (item: any) =>
169170
Object.fromEntries(

0 commit comments

Comments
 (0)