11<script setup lang="ts">
2- import { ref , PropType , watch , onUnmounted , computed } from " vue" ;
2+ import { ref , PropType , watch , onUnmounted , computed , useAttrs } from " vue" ;
33import Sortable , { SortableOptions } from " sortablejs" ;
44import type { AutoScrollOptions } from " sortablejs/plugins" ;
55
@@ -63,6 +63,8 @@ const emit = defineEmits<{
6363 (eventName : " change" , evt : Sortable .SortableEvent ): void ;
6464}>();
6565
66+ const attrs = useAttrs ()
67+
6668const containerRef = ref <HTMLElement | null >(null );
6769const sortable = ref <Sortable | null >(null );
6870const getKey = computed (() => {
@@ -84,7 +86,8 @@ watch(containerRef, (newDraggable) => {
8486 onSort : (event ) => emit (" sort" , event ),
8587 onRemove : (event ) => emit (" remove" , event ),
8688 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 ),
8891 onClone : (event ) => emit (" clone" , event ),
8992 onChange : (event ) => emit (" change" , event ),
9093 });
0 commit comments