1
1
<script setup lang="ts">
2
- import { ref , PropType , watch , onUnmounted , computed } from " vue" ;
2
+ import { ref , PropType , watch , onUnmounted , computed , useAttrs } from " vue" ;
3
3
import Sortable , { SortableOptions } from " sortablejs" ;
4
4
import type { AutoScrollOptions } from " sortablejs/plugins" ;
5
5
@@ -63,6 +63,8 @@ const emit = defineEmits<{
63
63
(eventName : " change" , evt : Sortable .SortableEvent ): void ;
64
64
}>();
65
65
66
+ const attrs = useAttrs ()
67
+
66
68
const containerRef = ref <HTMLElement | null >(null );
67
69
const sortable = ref <Sortable | null >(null );
68
70
const getKey = computed (() => {
@@ -84,7 +86,8 @@ watch(containerRef, (newDraggable) => {
84
86
onSort : (event ) => emit (" sort" , event ),
85
87
onRemove : (event ) => emit (" remove" , event ),
86
88
onFilter : (event ) => emit (" filter" , event ),
87
- onMove : (event , originalEvent ) => emit (" move" , event , originalEvent ),
89
+ // See https://github.com/MaxLeiter/sortablejs-vue3/pull/56 for context on `attrs`.
90
+ onMove : (event , originalEvent ) => " onMoveCapture" in attrs ? (<(event : Sortable .MoveEvent , originalEvent : Event ) => void >attrs .onMoveCapture )(event , originalEvent ) : emit (" move" , event , originalEvent ),
88
91
onClone : (event ) => emit (" clone" , event ),
89
92
onChange : (event ) => emit (" change" , event ),
90
93
});
0 commit comments