svelte-dnd-action
Advanced tools
Comparing version 0.9.37 to 0.9.38
{ | ||
"name": "svelte-dnd-action", | ||
"description": "*An awesome drag and drop library for Svelte 3 and 4 (not using the browser's built-in dnd, thanks god): Rich animations, nested containers, touch support and more *", | ||
"version": "0.9.37", | ||
"version": "0.9.38", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -186,2 +186,3 @@ # SVELTE DND ACTION [![Known Vulnerabilities](https://snyk.io/test/github/isaacHagoel/svelte-dnd-action/badge.svg?targetFile=package.json)](https://snyk.io/test/github/isaacHagoel/svelte-dnd-action?targetFile=package.json) | ||
- [Copy on drag, simple and Dragula like](https://svelte.dev/repl/924b4cc920524065a637fa910fe10193?version=3) | ||
- [Copy on drop and a drop area with a single slot](https://svelte.dev/repl/b4e120c45c3e48e49a0d637f0cf097d9?version=3) | ||
- [Drag handles](https://svelte.dev/repl/4949485c5a8f46e7bdbeb73ed565a9c7?version=3), courtesy of @gleuch | ||
@@ -188,0 +189,0 @@ - [Interaction (save/get items) with an asynchronous server](https://svelte.dev/repl/964fdac31cb9496da9ded35002300abb?version=3) |
@@ -120,2 +120,5 @@ import { | ||
} | ||
function createShadowElData(draggedElData) { | ||
return {...draggedElData, [SHADOW_ITEM_MARKER_PROPERTY_NAME]: true, [ITEM_ID_KEY]: SHADOW_PLACEHOLDER_ITEM_ID}; | ||
} | ||
@@ -161,3 +164,5 @@ /* custom drag-events handlers */ | ||
const shadowElIdx = findShadowElementIdx(items); | ||
const shadowItem = items.splice(shadowElIdx, 1)[0]; | ||
if (shadowElIdx !== -1) { | ||
items.splice(shadowElIdx, 1); | ||
} | ||
shadowElDropZone = undefined; | ||
@@ -173,3 +178,3 @@ const {type, theOtherDz} = e.detail; | ||
const originZoneItems = dzToConfig.get(originDropZone).items; | ||
originZoneItems.splice(originIndex, 0, shadowItem); | ||
originZoneItems.splice(originIndex, 0, shadowElData); | ||
dispatchConsiderEvent(originDropZone, originZoneItems, { | ||
@@ -198,3 +203,5 @@ trigger: TRIGGERS.DRAGGED_LEFT_ALL, | ||
const shadowElIdx = findShadowElementIdx(items); | ||
items.splice(shadowElIdx, 1); | ||
if (shadowElIdx !== -1) { | ||
items.splice(shadowElIdx, 1); | ||
} | ||
items.splice(index, 0, shadowElData); | ||
@@ -238,3 +245,9 @@ dispatchConsiderEvent(e.currentTarget, items, {trigger: TRIGGERS.DRAGGED_OVER_INDEX, id: draggedElData[ITEM_ID_KEY], source: SOURCES.POINTER}); | ||
// the handler might remove the shadow element, ex: dragula like copy on drag | ||
if (shadowElIdx === -1) shadowElIdx = originIndex; | ||
if (shadowElIdx === -1) { | ||
if (shadowElDropZone === originDropZone) { | ||
shadowElIdx = originIndex; | ||
} else if (shadowElDropZone.children.length > 0) { | ||
shadowElIdx = shadowElDropZone.children.length - 1; | ||
} | ||
} | ||
@@ -257,6 +270,6 @@ items = items.map(item => (item[SHADOW_ITEM_MARKER_PROPERTY_NAME] ? draggedElData : item)); | ||
} | ||
unDecorateShadowElement(shadowElDropZone.children[shadowElIdx]); | ||
if (shadowElIdx !== -1) unDecorateShadowElement(shadowElDropZone.children[shadowElIdx]); | ||
cleanupPostDrop(); | ||
} | ||
animateDraggedToFinalPosition(shadowElIdx, finalizeWithinZone); | ||
if (shadowElIdx !== -1) animateDraggedToFinalPosition(shadowElIdx, finalizeWithinZone); | ||
} | ||
@@ -398,3 +411,3 @@ | ||
draggedElType = type; | ||
shadowElData = {...draggedElData, [SHADOW_ITEM_MARKER_PROPERTY_NAME]: true, [ITEM_ID_KEY]: SHADOW_PLACEHOLDER_ITEM_ID}; | ||
shadowElData = createShadowElData(draggedElData); | ||
@@ -401,0 +414,0 @@ // creating the draggable element |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
296109
6884
383