Skip to content

Commit

Permalink
fix: fix v-draggable type error (#176)
Browse files Browse the repository at this point in the history
Co-authored-by: liliang18 <[email protected]>
  • Loading branch information
ArthurDarkstone and liliang18 authored Oct 17, 2024
1 parent 4c7aca6 commit f2a4930
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ const directiveHooks = {
}

type VDraggableBinding = [
list: Ref<any[]>,
list: RefOrValue<any[]>,
options?: RefOrValue<UseDraggableOptions<any>>
]

const elementMap: WeakMap<HTMLElement, () => void> = new WeakMap()

export const vDraggable: ObjectDirective<
HTMLElement,
VDraggableBinding | Ref<any[]>
VDraggableBinding | RefOrValue<any[]>
> = {
[directiveHooks.mounted](el, binding) {
const params = isProxy(binding.value) ? [binding.value] : binding.value

const state = useDraggable(el!, ...(params as VDraggableBinding))
const [list, options] = params as VDraggableBinding

const state = useDraggable(el!, list as Ref, options)
elementMap.set(el, state.destroy)
},
[directiveHooks.unmounted](el) {
Expand Down

0 comments on commit f2a4930

Please sign in to comment.