Skip to content

Commit

Permalink
adds comments, sets margin to 0 explicitly when using multi drag
Browse files Browse the repository at this point in the history
  • Loading branch information
sashamilenkovic committed Jan 2, 2025
1 parent 6d7cc97 commit 1aa4db2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,15 @@ export function dragStateProps<T>(
};
}

/**
* Perform the sort of the nodes.
*
* @param {ParentRecord<T>} parent - The parent record.
* @param {Array<NodeRecord<T>>} draggedNodes - The dragged nodes.
* @param {Array<NodeRecord<T>>} targetNodes - The target nodes.
*
* @returns void
*/
export function performSort<T>({
parent,
draggedNodes,
Expand Down Expand Up @@ -664,6 +673,14 @@ function setSelected<T>(
);
}

/**
* Update the live region.
*
* @param {ParentRecord<T>} parent - The parent record.
* @param {string} message - The message to update the live region with.
*
* @returns void
*/
function updateLiveRegion<T>(parent: ParentRecord<T>, message: string) {
const liveRegion = document.querySelector('[data-dnd-live-region="true"]');

Expand All @@ -674,6 +691,13 @@ function updateLiveRegion<T>(parent: ParentRecord<T>, message: string) {
liveRegion.textContent = message;
}

/**
* Clear the live region.
*
* @param {ParentRecord<T>} parent - The parent record.
*
* @returns void
*/
function clearLiveRegion<T>(parent: ParentRecord<T>) {
const liveRegion = document.getElementById(parent.el.id + "-live-region");

Expand All @@ -682,6 +706,14 @@ function clearLiveRegion<T>(parent: ParentRecord<T>) {
liveRegion.textContent = "";
}

/**
* Handle the parent focus event.
*
* @param {ParentEventData<T>} data - The parent event data.
* @param {BaseDragState<T> | DragState<T> | SynthDragState<T>} state - The drag state.
*
* @returns void
*/
export function handleParentFocus<T>(
data: ParentEventData<T>,
state: BaseDragState<T> | DragState<T> | SynthDragState<T>
Expand Down Expand Up @@ -2175,6 +2207,8 @@ function initSynthDrag<T>(

clonedNode.style.pointerEvents = "none";

clonedNode.style.margin = "0";

wrapper.append(clonedNode);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/.nuxt/nuxt.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Generated by nuxi
/// <reference types="@nuxtjs/tailwindcss" />
/// <reference types="@nuxt/telemetry" />
/// <reference types="@nuxt/devtools" />
/// <reference types="@nuxt/telemetry" />
/// <reference types="nuxt" />
/// <reference path="types/app-defaults.d.ts" />
/// <reference path="types/plugins.d.ts" />
Expand Down

0 comments on commit 1aa4db2

Please sign in to comment.