svelte-dnd-action 0.9.41 → 0.9.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/index.js +20 -9
- package/dist/index.mjs +20 -9
- package/package.json +1 -1
- package/src/pointerAction.js +21 -9
package/README.md
CHANGED
|
@@ -372,6 +372,13 @@ This is an experimental feature added in version 0.9.29. If you have multiple le
|
|
|
372
372
|
Specifically, it allows nested zones within the shadow element (the placeholder under the dragged element) to register and destroy.
|
|
373
373
|
This is because Svelte calls nested actions before the parent action (opposite to the rendering order).
|
|
374
374
|
You can use a data attribute **on the items** to help the lib prevent this: `data-is-dnd-shadow-item-hint={item[SHADOW_ITEM_MARKER_PROPERTY_NAME]} `
|
|
375
|
+
Starting with version 0.9.42. if you use the hint make sure to include it in the key you provide in your each block e.g:
|
|
376
|
+
|
|
377
|
+
```sveltehtml
|
|
378
|
+
{#each columnItems as column (`${column._id}${column[SHADOW_ITEM_MARKER_PROPERTY_NAME] ? "_" + column[SHADOW_ITEM_MARKER_PROPERTY_NAME] : ""}`)}
|
|
379
|
+
...
|
|
380
|
+
{/each}
|
|
381
|
+
```
|
|
375
382
|
|
|
376
383
|
#### Simplified Example (just shows where to place the attribute):
|
|
377
384
|
|
package/dist/index.js
CHANGED
|
@@ -1439,7 +1439,7 @@
|
|
|
1439
1439
|
return ["dragged left", e.currentTarget, e.detail];
|
|
1440
1440
|
});
|
|
1441
1441
|
var _dzToConfig$get2 = dzToConfig.get(e.currentTarget),
|
|
1442
|
-
|
|
1442
|
+
originalItems = _dzToConfig$get2.items,
|
|
1443
1443
|
dropFromOthersDisabled = _dzToConfig$get2.dropFromOthersDisabled;
|
|
1444
1444
|
if (dropFromOthersDisabled && e.currentTarget !== originDropZone && e.currentTarget !== shadowElDropZone) {
|
|
1445
1445
|
printDebug(function () {
|
|
@@ -1447,10 +1447,12 @@
|
|
|
1447
1447
|
});
|
|
1448
1448
|
return;
|
|
1449
1449
|
}
|
|
1450
|
+
var items = _toConsumableArray(originalItems);
|
|
1450
1451
|
var shadowElIdx = findShadowElementIdx(items);
|
|
1451
1452
|
if (shadowElIdx !== -1) {
|
|
1452
1453
|
items.splice(shadowElIdx, 1);
|
|
1453
1454
|
}
|
|
1455
|
+
var origShadowDz = shadowElDropZone;
|
|
1454
1456
|
shadowElDropZone = undefined;
|
|
1455
1457
|
var _e$detail = e.detail,
|
|
1456
1458
|
type = _e$detail.type,
|
|
@@ -1461,7 +1463,8 @@
|
|
|
1461
1463
|
});
|
|
1462
1464
|
isDraggedOutsideOfAnyDz = true;
|
|
1463
1465
|
shadowElDropZone = originDropZone;
|
|
1464
|
-
|
|
1466
|
+
// if the last zone it left is the origin dz, we will put it back into items (which we just removed it from)
|
|
1467
|
+
var originZoneItems = origShadowDz === originDropZone ? items : _toConsumableArray(dzToConfig.get(originDropZone).items);
|
|
1465
1468
|
originZoneItems.splice(originIndex, 0, shadowElData);
|
|
1466
1469
|
dispatchConsiderEvent(originDropZone, originZoneItems, {
|
|
1467
1470
|
trigger: TRIGGERS.DRAGGED_LEFT_ALL,
|
|
@@ -1481,7 +1484,7 @@
|
|
|
1481
1484
|
return ["dragged is over index", e.currentTarget, e.detail];
|
|
1482
1485
|
});
|
|
1483
1486
|
var _dzToConfig$get3 = dzToConfig.get(e.currentTarget),
|
|
1484
|
-
|
|
1487
|
+
originalItems = _dzToConfig$get3.items,
|
|
1485
1488
|
dropFromOthersDisabled = _dzToConfig$get3.dropFromOthersDisabled;
|
|
1486
1489
|
if (dropFromOthersDisabled && e.currentTarget !== originDropZone) {
|
|
1487
1490
|
printDebug(function () {
|
|
@@ -1489,6 +1492,7 @@
|
|
|
1489
1492
|
});
|
|
1490
1493
|
return;
|
|
1491
1494
|
}
|
|
1495
|
+
var items = _toConsumableArray(originalItems);
|
|
1492
1496
|
isDraggedOutsideOfAnyDz = false;
|
|
1493
1497
|
var index = e.detail.indexObj.index;
|
|
1494
1498
|
var shadowElIdx = findShadowElementIdx(items);
|
|
@@ -1547,8 +1551,6 @@
|
|
|
1547
1551
|
if (shadowElIdx === -1) {
|
|
1548
1552
|
if (shadowElDropZone === originDropZone) {
|
|
1549
1553
|
shadowElIdx = originIndex;
|
|
1550
|
-
} else if (shadowElDropZone.children.length > 0) {
|
|
1551
|
-
shadowElIdx = shadowElDropZone.children.length - 1;
|
|
1552
1554
|
}
|
|
1553
1555
|
}
|
|
1554
1556
|
items = items.map(function (item) {
|
|
@@ -1572,12 +1574,12 @@
|
|
|
1572
1574
|
if (shadowElIdx !== -1) unDecorateShadowElement(shadowElDropZone.children[shadowElIdx]);
|
|
1573
1575
|
cleanupPostDrop();
|
|
1574
1576
|
}
|
|
1575
|
-
|
|
1577
|
+
animateDraggedToFinalPosition(shadowElIdx, finalizeWithinZone);
|
|
1576
1578
|
}
|
|
1577
1579
|
|
|
1578
1580
|
// helper function for handleDrop
|
|
1579
1581
|
function animateDraggedToFinalPosition(shadowElIdx, callback) {
|
|
1580
|
-
var shadowElRect = getBoundingRectNoTransforms(shadowElDropZone.children[shadowElIdx]);
|
|
1582
|
+
var shadowElRect = shadowElIdx > -1 ? getBoundingRectNoTransforms(shadowElDropZone.children[shadowElIdx]) : getBoundingRectNoTransforms(shadowElDropZone);
|
|
1581
1583
|
var newTransform = {
|
|
1582
1584
|
x: shadowElRect.left - parseFloat(draggedEl.style.left),
|
|
1583
1585
|
y: shadowElRect.top - parseFloat(draggedEl.style.top)
|
|
@@ -1671,11 +1673,16 @@
|
|
|
1671
1673
|
window.removeEventListener("mouseup", handleFalseAlarm);
|
|
1672
1674
|
window.removeEventListener("touchend", handleFalseAlarm);
|
|
1673
1675
|
}
|
|
1674
|
-
function handleFalseAlarm() {
|
|
1676
|
+
function handleFalseAlarm(e) {
|
|
1675
1677
|
removeMaybeListeners();
|
|
1676
1678
|
originalDragTarget = undefined;
|
|
1677
1679
|
dragStartMousePosition = undefined;
|
|
1678
1680
|
currentMousePosition = undefined;
|
|
1681
|
+
|
|
1682
|
+
// dragging initiated by touch events prevents onclick from initially firing
|
|
1683
|
+
if (e.type === "touchend") {
|
|
1684
|
+
e.target.click();
|
|
1685
|
+
}
|
|
1679
1686
|
}
|
|
1680
1687
|
function handleMouseMoveMaybeDragStart(e) {
|
|
1681
1688
|
e.preventDefault();
|
|
@@ -1710,6 +1717,7 @@
|
|
|
1710
1717
|
});
|
|
1711
1718
|
return;
|
|
1712
1719
|
}
|
|
1720
|
+
e.preventDefault();
|
|
1713
1721
|
e.stopPropagation();
|
|
1714
1722
|
var c = e.touches ? e.touches[0] : e;
|
|
1715
1723
|
dragStartMousePosition = {
|
|
@@ -1733,9 +1741,10 @@
|
|
|
1733
1741
|
/** @type {ShadowRoot | HTMLDocument | Element } */
|
|
1734
1742
|
var rootNode = originDropZone.closest("dialog") || originDropZone.getRootNode();
|
|
1735
1743
|
var originDropZoneRoot = rootNode.body || rootNode;
|
|
1736
|
-
var
|
|
1744
|
+
var originalItems = config.items,
|
|
1737
1745
|
type = config.type,
|
|
1738
1746
|
centreDraggedOnCursor = config.centreDraggedOnCursor;
|
|
1747
|
+
var items = _toConsumableArray(originalItems);
|
|
1739
1748
|
draggedElData = items[currentIdx];
|
|
1740
1749
|
draggedElType = type;
|
|
1741
1750
|
shadowElData = createShadowElData(draggedElData);
|
|
@@ -1753,6 +1762,8 @@
|
|
|
1753
1762
|
watchDraggedElement();
|
|
1754
1763
|
hideElement(originalDragTarget);
|
|
1755
1764
|
originDropZoneRoot.appendChild(originalDragTarget);
|
|
1765
|
+
// after the removal of the original element we can give the shadow element the original item id so that the host zone can find it and render it correctly if it does lookups by id
|
|
1766
|
+
shadowElData[ITEM_ID_KEY] = draggedElData[ITEM_ID_KEY];
|
|
1756
1767
|
} else {
|
|
1757
1768
|
window.requestAnimationFrame(keepOriginalElementInDom);
|
|
1758
1769
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1433,7 +1433,7 @@ function handleDraggedLeft(e) {
|
|
|
1433
1433
|
return ["dragged left", e.currentTarget, e.detail];
|
|
1434
1434
|
});
|
|
1435
1435
|
var _dzToConfig$get2 = dzToConfig.get(e.currentTarget),
|
|
1436
|
-
|
|
1436
|
+
originalItems = _dzToConfig$get2.items,
|
|
1437
1437
|
dropFromOthersDisabled = _dzToConfig$get2.dropFromOthersDisabled;
|
|
1438
1438
|
if (dropFromOthersDisabled && e.currentTarget !== originDropZone && e.currentTarget !== shadowElDropZone) {
|
|
1439
1439
|
printDebug(function () {
|
|
@@ -1441,10 +1441,12 @@ function handleDraggedLeft(e) {
|
|
|
1441
1441
|
});
|
|
1442
1442
|
return;
|
|
1443
1443
|
}
|
|
1444
|
+
var items = _toConsumableArray(originalItems);
|
|
1444
1445
|
var shadowElIdx = findShadowElementIdx(items);
|
|
1445
1446
|
if (shadowElIdx !== -1) {
|
|
1446
1447
|
items.splice(shadowElIdx, 1);
|
|
1447
1448
|
}
|
|
1449
|
+
var origShadowDz = shadowElDropZone;
|
|
1448
1450
|
shadowElDropZone = undefined;
|
|
1449
1451
|
var _e$detail = e.detail,
|
|
1450
1452
|
type = _e$detail.type,
|
|
@@ -1455,7 +1457,8 @@ function handleDraggedLeft(e) {
|
|
|
1455
1457
|
});
|
|
1456
1458
|
isDraggedOutsideOfAnyDz = true;
|
|
1457
1459
|
shadowElDropZone = originDropZone;
|
|
1458
|
-
|
|
1460
|
+
// if the last zone it left is the origin dz, we will put it back into items (which we just removed it from)
|
|
1461
|
+
var originZoneItems = origShadowDz === originDropZone ? items : _toConsumableArray(dzToConfig.get(originDropZone).items);
|
|
1459
1462
|
originZoneItems.splice(originIndex, 0, shadowElData);
|
|
1460
1463
|
dispatchConsiderEvent(originDropZone, originZoneItems, {
|
|
1461
1464
|
trigger: TRIGGERS.DRAGGED_LEFT_ALL,
|
|
@@ -1475,7 +1478,7 @@ function handleDraggedIsOverIndex(e) {
|
|
|
1475
1478
|
return ["dragged is over index", e.currentTarget, e.detail];
|
|
1476
1479
|
});
|
|
1477
1480
|
var _dzToConfig$get3 = dzToConfig.get(e.currentTarget),
|
|
1478
|
-
|
|
1481
|
+
originalItems = _dzToConfig$get3.items,
|
|
1479
1482
|
dropFromOthersDisabled = _dzToConfig$get3.dropFromOthersDisabled;
|
|
1480
1483
|
if (dropFromOthersDisabled && e.currentTarget !== originDropZone) {
|
|
1481
1484
|
printDebug(function () {
|
|
@@ -1483,6 +1486,7 @@ function handleDraggedIsOverIndex(e) {
|
|
|
1483
1486
|
});
|
|
1484
1487
|
return;
|
|
1485
1488
|
}
|
|
1489
|
+
var items = _toConsumableArray(originalItems);
|
|
1486
1490
|
isDraggedOutsideOfAnyDz = false;
|
|
1487
1491
|
var index = e.detail.indexObj.index;
|
|
1488
1492
|
var shadowElIdx = findShadowElementIdx(items);
|
|
@@ -1541,8 +1545,6 @@ function handleDrop() {
|
|
|
1541
1545
|
if (shadowElIdx === -1) {
|
|
1542
1546
|
if (shadowElDropZone === originDropZone) {
|
|
1543
1547
|
shadowElIdx = originIndex;
|
|
1544
|
-
} else if (shadowElDropZone.children.length > 0) {
|
|
1545
|
-
shadowElIdx = shadowElDropZone.children.length - 1;
|
|
1546
1548
|
}
|
|
1547
1549
|
}
|
|
1548
1550
|
items = items.map(function (item) {
|
|
@@ -1566,12 +1568,12 @@ function handleDrop() {
|
|
|
1566
1568
|
if (shadowElIdx !== -1) unDecorateShadowElement(shadowElDropZone.children[shadowElIdx]);
|
|
1567
1569
|
cleanupPostDrop();
|
|
1568
1570
|
}
|
|
1569
|
-
|
|
1571
|
+
animateDraggedToFinalPosition(shadowElIdx, finalizeWithinZone);
|
|
1570
1572
|
}
|
|
1571
1573
|
|
|
1572
1574
|
// helper function for handleDrop
|
|
1573
1575
|
function animateDraggedToFinalPosition(shadowElIdx, callback) {
|
|
1574
|
-
var shadowElRect = getBoundingRectNoTransforms(shadowElDropZone.children[shadowElIdx]);
|
|
1576
|
+
var shadowElRect = shadowElIdx > -1 ? getBoundingRectNoTransforms(shadowElDropZone.children[shadowElIdx]) : getBoundingRectNoTransforms(shadowElDropZone);
|
|
1575
1577
|
var newTransform = {
|
|
1576
1578
|
x: shadowElRect.left - parseFloat(draggedEl.style.left),
|
|
1577
1579
|
y: shadowElRect.top - parseFloat(draggedEl.style.top)
|
|
@@ -1665,11 +1667,16 @@ function dndzone(node, options) {
|
|
|
1665
1667
|
window.removeEventListener("mouseup", handleFalseAlarm);
|
|
1666
1668
|
window.removeEventListener("touchend", handleFalseAlarm);
|
|
1667
1669
|
}
|
|
1668
|
-
function handleFalseAlarm() {
|
|
1670
|
+
function handleFalseAlarm(e) {
|
|
1669
1671
|
removeMaybeListeners();
|
|
1670
1672
|
originalDragTarget = undefined;
|
|
1671
1673
|
dragStartMousePosition = undefined;
|
|
1672
1674
|
currentMousePosition = undefined;
|
|
1675
|
+
|
|
1676
|
+
// dragging initiated by touch events prevents onclick from initially firing
|
|
1677
|
+
if (e.type === "touchend") {
|
|
1678
|
+
e.target.click();
|
|
1679
|
+
}
|
|
1673
1680
|
}
|
|
1674
1681
|
function handleMouseMoveMaybeDragStart(e) {
|
|
1675
1682
|
e.preventDefault();
|
|
@@ -1704,6 +1711,7 @@ function dndzone(node, options) {
|
|
|
1704
1711
|
});
|
|
1705
1712
|
return;
|
|
1706
1713
|
}
|
|
1714
|
+
e.preventDefault();
|
|
1707
1715
|
e.stopPropagation();
|
|
1708
1716
|
var c = e.touches ? e.touches[0] : e;
|
|
1709
1717
|
dragStartMousePosition = {
|
|
@@ -1727,9 +1735,10 @@ function dndzone(node, options) {
|
|
|
1727
1735
|
/** @type {ShadowRoot | HTMLDocument | Element } */
|
|
1728
1736
|
var rootNode = originDropZone.closest("dialog") || originDropZone.getRootNode();
|
|
1729
1737
|
var originDropZoneRoot = rootNode.body || rootNode;
|
|
1730
|
-
var
|
|
1738
|
+
var originalItems = config.items,
|
|
1731
1739
|
type = config.type,
|
|
1732
1740
|
centreDraggedOnCursor = config.centreDraggedOnCursor;
|
|
1741
|
+
var items = _toConsumableArray(originalItems);
|
|
1733
1742
|
draggedElData = items[currentIdx];
|
|
1734
1743
|
draggedElType = type;
|
|
1735
1744
|
shadowElData = createShadowElData(draggedElData);
|
|
@@ -1747,6 +1756,8 @@ function dndzone(node, options) {
|
|
|
1747
1756
|
watchDraggedElement();
|
|
1748
1757
|
hideElement(originalDragTarget);
|
|
1749
1758
|
originDropZoneRoot.appendChild(originalDragTarget);
|
|
1759
|
+
// after the removal of the original element we can give the shadow element the original item id so that the host zone can find it and render it correctly if it does lookups by id
|
|
1760
|
+
shadowElData[ITEM_ID_KEY] = draggedElData[ITEM_ID_KEY];
|
|
1750
1761
|
} else {
|
|
1751
1762
|
window.requestAnimationFrame(keepOriginalElementInDom);
|
|
1752
1763
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-dnd-action",
|
|
3
3
|
"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 *",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.43",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/isaacHagoel/svelte-dnd-action.git"
|
package/src/pointerAction.js
CHANGED
|
@@ -155,15 +155,17 @@ function handleDraggedLeft(e) {
|
|
|
155
155
|
// dealing with a rare race condition on extremely rapid clicking and dropping
|
|
156
156
|
if (!isWorkingOnPreviousDrag) return;
|
|
157
157
|
printDebug(() => ["dragged left", e.currentTarget, e.detail]);
|
|
158
|
-
const {items, dropFromOthersDisabled} = dzToConfig.get(e.currentTarget);
|
|
158
|
+
const {items: originalItems, dropFromOthersDisabled} = dzToConfig.get(e.currentTarget);
|
|
159
159
|
if (dropFromOthersDisabled && e.currentTarget !== originDropZone && e.currentTarget !== shadowElDropZone) {
|
|
160
160
|
printDebug(() => "drop is currently disabled");
|
|
161
161
|
return;
|
|
162
162
|
}
|
|
163
|
+
const items = [...originalItems];
|
|
163
164
|
const shadowElIdx = findShadowElementIdx(items);
|
|
164
165
|
if (shadowElIdx !== -1) {
|
|
165
166
|
items.splice(shadowElIdx, 1);
|
|
166
167
|
}
|
|
168
|
+
const origShadowDz = shadowElDropZone;
|
|
167
169
|
shadowElDropZone = undefined;
|
|
168
170
|
const {type, theOtherDz} = e.detail;
|
|
169
171
|
if (
|
|
@@ -173,7 +175,8 @@ function handleDraggedLeft(e) {
|
|
|
173
175
|
printDebug(() => "dragged left all, putting shadow element back in the origin dz");
|
|
174
176
|
isDraggedOutsideOfAnyDz = true;
|
|
175
177
|
shadowElDropZone = originDropZone;
|
|
176
|
-
|
|
178
|
+
// if the last zone it left is the origin dz, we will put it back into items (which we just removed it from)
|
|
179
|
+
const originZoneItems = origShadowDz === originDropZone ? items : [...dzToConfig.get(originDropZone).items];
|
|
177
180
|
originZoneItems.splice(originIndex, 0, shadowElData);
|
|
178
181
|
dispatchConsiderEvent(originDropZone, originZoneItems, {
|
|
179
182
|
trigger: TRIGGERS.DRAGGED_LEFT_ALL,
|
|
@@ -190,11 +193,12 @@ function handleDraggedLeft(e) {
|
|
|
190
193
|
}
|
|
191
194
|
function handleDraggedIsOverIndex(e) {
|
|
192
195
|
printDebug(() => ["dragged is over index", e.currentTarget, e.detail]);
|
|
193
|
-
const {items, dropFromOthersDisabled} = dzToConfig.get(e.currentTarget);
|
|
196
|
+
const {items: originalItems, dropFromOthersDisabled} = dzToConfig.get(e.currentTarget);
|
|
194
197
|
if (dropFromOthersDisabled && e.currentTarget !== originDropZone) {
|
|
195
198
|
printDebug(() => "drop is currently disabled");
|
|
196
199
|
return;
|
|
197
200
|
}
|
|
201
|
+
const items = [...originalItems];
|
|
198
202
|
isDraggedOutsideOfAnyDz = false;
|
|
199
203
|
const {index} = e.detail.indexObj;
|
|
200
204
|
const shadowElIdx = findShadowElementIdx(items);
|
|
@@ -242,8 +246,6 @@ function handleDrop() {
|
|
|
242
246
|
if (shadowElIdx === -1) {
|
|
243
247
|
if (shadowElDropZone === originDropZone) {
|
|
244
248
|
shadowElIdx = originIndex;
|
|
245
|
-
} else if (shadowElDropZone.children.length > 0) {
|
|
246
|
-
shadowElIdx = shadowElDropZone.children.length - 1;
|
|
247
249
|
}
|
|
248
250
|
}
|
|
249
251
|
|
|
@@ -266,12 +268,13 @@ function handleDrop() {
|
|
|
266
268
|
if (shadowElIdx !== -1) unDecorateShadowElement(shadowElDropZone.children[shadowElIdx]);
|
|
267
269
|
cleanupPostDrop();
|
|
268
270
|
}
|
|
269
|
-
|
|
271
|
+
animateDraggedToFinalPosition(shadowElIdx, finalizeWithinZone);
|
|
270
272
|
}
|
|
271
273
|
|
|
272
274
|
// helper function for handleDrop
|
|
273
275
|
function animateDraggedToFinalPosition(shadowElIdx, callback) {
|
|
274
|
-
const shadowElRect =
|
|
276
|
+
const shadowElRect =
|
|
277
|
+
shadowElIdx > -1 ? getBoundingRectNoTransforms(shadowElDropZone.children[shadowElIdx]) : getBoundingRectNoTransforms(shadowElDropZone);
|
|
275
278
|
const newTransform = {
|
|
276
279
|
x: shadowElRect.left - parseFloat(draggedEl.style.left),
|
|
277
280
|
y: shadowElRect.top - parseFloat(draggedEl.style.top)
|
|
@@ -347,11 +350,16 @@ export function dndzone(node, options) {
|
|
|
347
350
|
window.removeEventListener("mouseup", handleFalseAlarm);
|
|
348
351
|
window.removeEventListener("touchend", handleFalseAlarm);
|
|
349
352
|
}
|
|
350
|
-
function handleFalseAlarm() {
|
|
353
|
+
function handleFalseAlarm(e) {
|
|
351
354
|
removeMaybeListeners();
|
|
352
355
|
originalDragTarget = undefined;
|
|
353
356
|
dragStartMousePosition = undefined;
|
|
354
357
|
currentMousePosition = undefined;
|
|
358
|
+
|
|
359
|
+
// dragging initiated by touch events prevents onclick from initially firing
|
|
360
|
+
if (e.type === "touchend") {
|
|
361
|
+
e.target.click();
|
|
362
|
+
}
|
|
355
363
|
}
|
|
356
364
|
|
|
357
365
|
function handleMouseMoveMaybeDragStart(e) {
|
|
@@ -381,6 +389,7 @@ export function dndzone(node, options) {
|
|
|
381
389
|
printDebug(() => "cannot start a new drag before finalizing previous one");
|
|
382
390
|
return;
|
|
383
391
|
}
|
|
392
|
+
e.preventDefault();
|
|
384
393
|
e.stopPropagation();
|
|
385
394
|
const c = e.touches ? e.touches[0] : e;
|
|
386
395
|
dragStartMousePosition = {x: c.clientX, y: c.clientY};
|
|
@@ -400,7 +409,8 @@ export function dndzone(node, options) {
|
|
|
400
409
|
/** @type {ShadowRoot | HTMLDocument | Element } */
|
|
401
410
|
const rootNode = originDropZone.closest("dialog") || originDropZone.getRootNode();
|
|
402
411
|
const originDropZoneRoot = rootNode.body || rootNode;
|
|
403
|
-
const {items, type, centreDraggedOnCursor} = config;
|
|
412
|
+
const {items: originalItems, type, centreDraggedOnCursor} = config;
|
|
413
|
+
const items = [...originalItems];
|
|
404
414
|
draggedElData = items[currentIdx];
|
|
405
415
|
draggedElType = type;
|
|
406
416
|
shadowElData = createShadowElData(draggedElData);
|
|
@@ -418,6 +428,8 @@ export function dndzone(node, options) {
|
|
|
418
428
|
watchDraggedElement();
|
|
419
429
|
hideElement(originalDragTarget);
|
|
420
430
|
originDropZoneRoot.appendChild(originalDragTarget);
|
|
431
|
+
// after the removal of the original element we can give the shadow element the original item id so that the host zone can find it and render it correctly if it does lookups by id
|
|
432
|
+
shadowElData[ITEM_ID_KEY] = draggedElData[ITEM_ID_KEY];
|
|
421
433
|
} else {
|
|
422
434
|
window.requestAnimationFrame(keepOriginalElementInDom);
|
|
423
435
|
}
|