Skip to content

Commit

Permalink
changes selections to multi drag.
Browse files Browse the repository at this point in the history
  • Loading branch information
sashamilenkovic committed Jan 23, 2024
1 parent ffbc5a6 commit 8b27549
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions docs/pages/playground.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -37,8 +37,8 @@ onMounted(() => {
},
plugins: [
dropZone({}),
selections({
setSelections(parent) {
multiDrag({
selections(parent) {
return [parent.children[2]];
//return [parent.children[1]];
},
Expand All @@ -56,7 +56,7 @@ onMounted(() => {
draggable: (child: HTMLElement) => {
return child.classList.contains("item");
},
plugins: [dropZone({}), selections({})],
plugins: [dropZone({})],
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {

import { isNode, handleClass } from "../../utils";

export function selections(selectionsConfig: Partial<SelectionsConfig> = {}) {
export function multiDrag(multiDragConfig: Partial<MultiDragConfig> = {}) {
return (parent: HTMLElement) => {
const parentData = parents.get(parent);

Expand All @@ -26,10 +26,10 @@ export function selections(selectionsConfig: Partial<SelectionsConfig> = {}) {
},

setupParent() {
parentData.config.selectionsConfig = selectionsConfig;
parentData.config.multiDragConfig = multiDragConfig;

parentData.config.handleDragstart =
selectionsConfig.handleDragstart || selectionsDragstart;
multiDragConfig.handleDragstart || selectionsDragstart;

remapNodes(parent);
},
Expand All @@ -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();
Expand Down
File renamed without changes.

0 comments on commit 8b27549

Please sign in to comment.