mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-27 17:52:16 +00:00
[Cleanup] Rename usePragmaticDroppable to usePragmaticDragAndDrop (#2441)
This commit is contained in:
59
src/composables/usePragmaticDragAndDrop.ts
Normal file
59
src/composables/usePragmaticDragAndDrop.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import {
|
||||
draggable,
|
||||
dropTargetForElements
|
||||
} from '@atlaskit/pragmatic-drag-and-drop/element/adapter'
|
||||
import { onBeforeUnmount, onMounted } from 'vue'
|
||||
|
||||
export function usePragmaticDroppable(
|
||||
dropTargetElement: HTMLElement | (() => HTMLElement),
|
||||
options: Omit<Parameters<typeof dropTargetForElements>[0], 'element'>
|
||||
) {
|
||||
let cleanup = () => {}
|
||||
|
||||
onMounted(() => {
|
||||
const element =
|
||||
typeof dropTargetElement === 'function'
|
||||
? dropTargetElement()
|
||||
: dropTargetElement
|
||||
|
||||
if (!element) {
|
||||
return
|
||||
}
|
||||
|
||||
cleanup = dropTargetForElements({
|
||||
element,
|
||||
...options
|
||||
})
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
cleanup()
|
||||
})
|
||||
}
|
||||
|
||||
export function usePragmaticDraggable(
|
||||
draggableElement: HTMLElement | (() => HTMLElement),
|
||||
options: Omit<Parameters<typeof draggable>[0], 'element'>
|
||||
) {
|
||||
let cleanup = () => {}
|
||||
|
||||
onMounted(() => {
|
||||
const element =
|
||||
typeof draggableElement === 'function'
|
||||
? draggableElement()
|
||||
: draggableElement
|
||||
|
||||
if (!element) {
|
||||
return
|
||||
}
|
||||
|
||||
cleanup = draggable({
|
||||
element,
|
||||
...options
|
||||
})
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
cleanup()
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user