From 8b27549812b5129598cf7496daa88668abf52398 Mon Sep 17 00:00:00 2001 From: Sasha Milenkovic Date: Tue, 23 Jan 2024 15:15:09 -0500 Subject: [PATCH] changes selections to multi drag. --- docs/pages/playground.vue | 8 ++++---- src/plugins/{selections => multiDrag}/index.ts | 12 ++++++------ src/plugins/{selections => multiDrag}/types.ts | 0 3 files changed, 10 insertions(+), 10 deletions(-) rename src/plugins/{selections => multiDrag}/index.ts (91%) rename src/plugins/{selections => multiDrag}/types.ts (100%) diff --git a/docs/pages/playground.vue b/docs/pages/playground.vue index ca57d05..559e45c 100644 --- a/docs/pages/playground.vue +++ b/docs/pages/playground.vue @@ -4,7 +4,7 @@ import { dragAndDrop } from "../../src/vue/index"; //import { dropZone } from "../../src/vue/dropZone"; import { dropZone } from "../../src/plugins/dropZones/vue/index"; -import { selections } from "../../src/plugins/selections/index"; +import { multiDrag } from "../../src/plugins/multiDrag/index"; let firstList = ref(null); let secondList = ref(null); @@ -37,8 +37,8 @@ onMounted(() => { }, plugins: [ dropZone({}), - selections({ - setSelections(parent) { + multiDrag({ + selections(parent) { return [parent.children[2]]; //return [parent.children[1]]; }, @@ -56,7 +56,7 @@ onMounted(() => { draggable: (child: HTMLElement) => { return child.classList.contains("item"); }, - plugins: [dropZone({}), selections({})], + plugins: [dropZone({})], }); }); diff --git a/src/plugins/selections/index.ts b/src/plugins/multiDrag/index.ts similarity index 91% rename from src/plugins/selections/index.ts rename to src/plugins/multiDrag/index.ts index e9a2e93..5a4fea3 100644 --- a/src/plugins/selections/index.ts +++ b/src/plugins/multiDrag/index.ts @@ -12,7 +12,7 @@ import { import { isNode, handleClass } from "../../utils"; -export function selections(selectionsConfig: Partial = {}) { +export function multiDrag(multiDragConfig: Partial = {}) { return (parent: HTMLElement) => { const parentData = parents.get(parent); @@ -26,10 +26,10 @@ export function selections(selectionsConfig: Partial = {}) { }, setupParent() { - parentData.config.selectionsConfig = selectionsConfig; + parentData.config.multiDragConfig = multiDragConfig; parentData.config.handleDragstart = - selectionsConfig.handleDragstart || selectionsDragstart; + multiDragConfig.handleDragstart || selectionsDragstart; remapNodes(parent); }, @@ -50,11 +50,11 @@ function selectionsDragstart(data: NodeEventData) { data.e.dataTransfer.effectAllowed = "move"; } - const selectionsConfig = data.targetData.parent.data.config.selectionsConfig; + const multiDragConfig = data.targetData.parent.data.config.multiDragConfig; const selectedNodes = - selectionsConfig.setSelections && - selectionsConfig.setSelections(data.targetData.parent.el); + multiDragConfig.selections && + multiDragConfig.selections(data.targetData.parent.el); if (Array.isArray(selectedNodes) && selectedNodes.length) { const targetRect = data.targetData.node.el.getBoundingClientRect(); diff --git a/src/plugins/selections/types.ts b/src/plugins/multiDrag/types.ts similarity index 100% rename from src/plugins/selections/types.ts rename to src/plugins/multiDrag/types.ts