Skip to content

Commit

Permalink
Lots of drag-and-drop improvements
Browse files Browse the repository at this point in the history
- Allow dropping into collapsed groups and folders. Closes #407.
- Allows dragging and dropping between top-level and child groups.
- Removes the "Convert to Child/Top-Level" group menu items since
  they're not needed anymore.
  • Loading branch information
josh-berry committed Dec 8, 2024
2 parents 57050dd + 6af899b commit 1919785
Show file tree
Hide file tree
Showing 14 changed files with 848 additions and 725 deletions.
58 changes: 58 additions & 0 deletions src/components/dnd-directives.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import type {Directive} from "vue";

import {
makeDraggable,
makeDroppable,
type DNDLifecycle,
type DraggableOptions,
type DroppableOptions,
} from "./dnd.js";

const draggableElements = new WeakMap<
HTMLElement,
DNDLifecycle<DraggableOptions>
>();
const droppableElements = new WeakMap<
HTMLElement,
DNDLifecycle<DroppableOptions>
>();

export const vDraggable: Directive<
HTMLElement,
DraggableOptions,
never,
never
> = {
mounted(el, binding) {
draggableElements.set(el, makeDraggable(el, binding.value));
},
updated(el, binding) {
const l = draggableElements.get(el);
if (l) l.update(binding.value);
},
unmounted(el) {
const l = draggableElements.get(el);
if (l) l.cancel();
draggableElements.delete(el);
},
};

export const vDroppable: Directive<
HTMLElement,
DroppableOptions,
never,
never
> = {
mounted(el, binding) {
droppableElements.set(el, makeDroppable(el, binding.value));
},
updated(el, binding) {
const l = droppableElements.get(el);
if (l) l.update(binding.value);
},
unmounted(el) {
const l = droppableElements.get(el);
if (l) l.cancel();
droppableElements.delete(el);
},
};
12 changes: 0 additions & 12 deletions src/components/dnd-list.ts

This file was deleted.

Loading

0 comments on commit 1919785

Please sign in to comment.