svelte-dnd-action 0.9.46 → 0.9.48
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 +2 -1
- package/dist/index.js +11 -4
- package/dist/index.mjs +11 -4
- package/package.json +1 -1
- package/src/helpers/multiScroller.js +3 -2
- package/src/helpers/scroller.js +2 -2
- package/src/pointerAction.js +4 -1
package/README.md
CHANGED
|
@@ -251,7 +251,8 @@ Notes:
|
|
|
251
251
|
|
|
252
252
|
- [Copy on drag, simple and Dragula like](https://svelte.dev/repl/924b4cc920524065a637fa910fe10193?version=3)
|
|
253
253
|
- [Copy on drop and a drop area with a single slot](https://svelte.dev/repl/b4e120c45c3e48e49a0d637f0cf097d9?version=3)
|
|
254
|
-
- [Drag handles](https://svelte.dev/repl/
|
|
254
|
+
- [Drag handles using wrapper actions](https://svelte.dev/repl/cc1bc63be7a74830b4c97d428f62054d?version=4.2.17), for nested scenarios (same usage, it "just works"), see [here](https://svelte.dev/repl/4f7cbeb7b11b470b948e9af03b82a073?version=4.2.17) and [here](https://svelte.dev/repl/47c5f52f4c774cad8c367516395c7f99?version=4.2.17)
|
|
255
|
+
- [Drag handles - legacy](https://svelte.dev/repl/4949485c5a8f46e7bdbeb73ed565a9c7?version=3), use before version 0.9.46, courtesy of @gleuch
|
|
255
256
|
- [Interaction (save/get items) with an asynchronous server](https://svelte.dev/repl/964fdac31cb9496da9ded35002300abb?version=3)
|
|
256
257
|
- [Unsortable lists with custom aria instructions](https://svelte.dev/repl/e020ea1051dc4ae3ac2b697064f234bc?version=3)
|
|
257
258
|
- [Crazy nesting](https://svelte.dev/repl/fe8c9eca04f9417a94a8b6041df77139?version=3), courtesy of @zahachtah
|
package/dist/index.js
CHANGED
|
@@ -807,11 +807,11 @@
|
|
|
807
807
|
return false;
|
|
808
808
|
}
|
|
809
809
|
var distances = calcInnerDistancesBetweenPointAndSidesOfElement(pointer, elementToScroll);
|
|
810
|
+
var isAlreadyScrolling = !!scrollingInfo.directionObj;
|
|
810
811
|
if (distances === null) {
|
|
811
|
-
resetScrolling();
|
|
812
|
+
if (isAlreadyScrolling) resetScrolling();
|
|
812
813
|
return false;
|
|
813
814
|
}
|
|
814
|
-
var isAlreadyScrolling = !!scrollingInfo.directionObj;
|
|
815
815
|
var scrollingVertically = false,
|
|
816
816
|
scrollingHorizontally = false;
|
|
817
817
|
// vertical
|
|
@@ -912,7 +912,8 @@
|
|
|
912
912
|
return getDepth(dz2) - getDepth(dz1);
|
|
913
913
|
});
|
|
914
914
|
var _makeScroller = makeScroller(),
|
|
915
|
-
scrollIfNeeded = _makeScroller.scrollIfNeeded
|
|
915
|
+
scrollIfNeeded = _makeScroller.scrollIfNeeded,
|
|
916
|
+
resetScrolling = _makeScroller.resetScrolling;
|
|
916
917
|
|
|
917
918
|
/**
|
|
918
919
|
* @return {boolean} - was any container scrolled
|
|
@@ -936,6 +937,9 @@
|
|
|
936
937
|
return {
|
|
937
938
|
multiScrollIfNeeded: scrollingContainersSet.size > 0 ? tick : function () {
|
|
938
939
|
return false;
|
|
940
|
+
},
|
|
941
|
+
destroy: function destroy() {
|
|
942
|
+
return resetScrolling();
|
|
939
943
|
}
|
|
940
944
|
};
|
|
941
945
|
}
|
|
@@ -1294,6 +1298,7 @@
|
|
|
1294
1298
|
var unlockOriginDzMinDimensions;
|
|
1295
1299
|
var isDraggedOutsideOfAnyDz = false;
|
|
1296
1300
|
var scheduledForRemovalAfterDrop = [];
|
|
1301
|
+
var multiScroller;
|
|
1297
1302
|
|
|
1298
1303
|
// a map from type to a set of drop-zones
|
|
1299
1304
|
var typeToDropZones = new Map();
|
|
@@ -1350,7 +1355,7 @@
|
|
|
1350
1355
|
return dzToConfig.get(dz).dropAnimationDurationMs;
|
|
1351
1356
|
})));
|
|
1352
1357
|
var observationIntervalMs = setIntervalMs === 0 ? DISABLED_OBSERVATION_INTERVAL_MS : Math.max(setIntervalMs, MIN_OBSERVATION_INTERVAL_MS); // if setIntervalMs is 0 it goes to 20, otherwise it is max between it and min observation.
|
|
1353
|
-
|
|
1358
|
+
multiScroller = createMultiScroller(dropZones, function () {
|
|
1354
1359
|
return currentMousePosition;
|
|
1355
1360
|
});
|
|
1356
1361
|
observe(draggedEl, dropZones, observationIntervalMs * 1.07, multiScroller);
|
|
@@ -1375,6 +1380,8 @@
|
|
|
1375
1380
|
_iterator2.f();
|
|
1376
1381
|
}
|
|
1377
1382
|
window.removeEventListener(DRAGGED_LEFT_DOCUMENT_EVENT_NAME, handleDrop);
|
|
1383
|
+
multiScroller.destroy();
|
|
1384
|
+
multiScroller = undefined;
|
|
1378
1385
|
unobserve();
|
|
1379
1386
|
}
|
|
1380
1387
|
function findShadowElementIdx(items) {
|
package/dist/index.mjs
CHANGED
|
@@ -801,11 +801,11 @@ function makeScroller() {
|
|
|
801
801
|
return false;
|
|
802
802
|
}
|
|
803
803
|
var distances = calcInnerDistancesBetweenPointAndSidesOfElement(pointer, elementToScroll);
|
|
804
|
+
var isAlreadyScrolling = !!scrollingInfo.directionObj;
|
|
804
805
|
if (distances === null) {
|
|
805
|
-
resetScrolling();
|
|
806
|
+
if (isAlreadyScrolling) resetScrolling();
|
|
806
807
|
return false;
|
|
807
808
|
}
|
|
808
|
-
var isAlreadyScrolling = !!scrollingInfo.directionObj;
|
|
809
809
|
var scrollingVertically = false,
|
|
810
810
|
scrollingHorizontally = false;
|
|
811
811
|
// vertical
|
|
@@ -906,7 +906,8 @@ function createMultiScroller() {
|
|
|
906
906
|
return getDepth(dz2) - getDepth(dz1);
|
|
907
907
|
});
|
|
908
908
|
var _makeScroller = makeScroller(),
|
|
909
|
-
scrollIfNeeded = _makeScroller.scrollIfNeeded
|
|
909
|
+
scrollIfNeeded = _makeScroller.scrollIfNeeded,
|
|
910
|
+
resetScrolling = _makeScroller.resetScrolling;
|
|
910
911
|
|
|
911
912
|
/**
|
|
912
913
|
* @return {boolean} - was any container scrolled
|
|
@@ -930,6 +931,9 @@ function createMultiScroller() {
|
|
|
930
931
|
return {
|
|
931
932
|
multiScrollIfNeeded: scrollingContainersSet.size > 0 ? tick : function () {
|
|
932
933
|
return false;
|
|
934
|
+
},
|
|
935
|
+
destroy: function destroy() {
|
|
936
|
+
return resetScrolling();
|
|
933
937
|
}
|
|
934
938
|
};
|
|
935
939
|
}
|
|
@@ -1288,6 +1292,7 @@ var finalizingPreviousDrag = false;
|
|
|
1288
1292
|
var unlockOriginDzMinDimensions;
|
|
1289
1293
|
var isDraggedOutsideOfAnyDz = false;
|
|
1290
1294
|
var scheduledForRemovalAfterDrop = [];
|
|
1295
|
+
var multiScroller;
|
|
1291
1296
|
|
|
1292
1297
|
// a map from type to a set of drop-zones
|
|
1293
1298
|
var typeToDropZones = new Map();
|
|
@@ -1344,7 +1349,7 @@ function watchDraggedElement() {
|
|
|
1344
1349
|
return dzToConfig.get(dz).dropAnimationDurationMs;
|
|
1345
1350
|
})));
|
|
1346
1351
|
var observationIntervalMs = setIntervalMs === 0 ? DISABLED_OBSERVATION_INTERVAL_MS : Math.max(setIntervalMs, MIN_OBSERVATION_INTERVAL_MS); // if setIntervalMs is 0 it goes to 20, otherwise it is max between it and min observation.
|
|
1347
|
-
|
|
1352
|
+
multiScroller = createMultiScroller(dropZones, function () {
|
|
1348
1353
|
return currentMousePosition;
|
|
1349
1354
|
});
|
|
1350
1355
|
observe(draggedEl, dropZones, observationIntervalMs * 1.07, multiScroller);
|
|
@@ -1369,6 +1374,8 @@ function unWatchDraggedElement() {
|
|
|
1369
1374
|
_iterator2.f();
|
|
1370
1375
|
}
|
|
1371
1376
|
window.removeEventListener(DRAGGED_LEFT_DOCUMENT_EVENT_NAME, handleDrop);
|
|
1377
|
+
multiScroller.destroy();
|
|
1378
|
+
multiScroller = undefined;
|
|
1372
1379
|
unobserve();
|
|
1373
1380
|
}
|
|
1374
1381
|
function findShadowElementIdx(items) {
|
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.48",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/isaacHagoel/svelte-dnd-action.git"
|
|
@@ -16,7 +16,7 @@ export function createMultiScroller(baseElementsForScrolling = [], getPointerPos
|
|
|
16
16
|
printDebug(() => "creating multi-scroller");
|
|
17
17
|
const scrollingContainersSet = findRelevantScrollContainers(baseElementsForScrolling);
|
|
18
18
|
const scrollingContainersDeepToShallow = Array.from(scrollingContainersSet).sort((dz1, dz2) => getDepth(dz2) - getDepth(dz1));
|
|
19
|
-
const {scrollIfNeeded} = makeScroller();
|
|
19
|
+
const {scrollIfNeeded, resetScrolling} = makeScroller();
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* @return {boolean} - was any container scrolled
|
|
@@ -38,7 +38,8 @@ export function createMultiScroller(baseElementsForScrolling = [], getPointerPos
|
|
|
38
38
|
return false;
|
|
39
39
|
}
|
|
40
40
|
return {
|
|
41
|
-
multiScrollIfNeeded: scrollingContainersSet.size > 0 ? tick : () => false
|
|
41
|
+
multiScrollIfNeeded: scrollingContainersSet.size > 0 ? tick : () => false,
|
|
42
|
+
destroy: () => resetScrolling()
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
|
package/src/helpers/scroller.js
CHANGED
|
@@ -35,11 +35,11 @@ export function makeScroller() {
|
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
37
|
const distances = calcInnerDistancesBetweenPointAndSidesOfElement(pointer, elementToScroll);
|
|
38
|
+
const isAlreadyScrolling = !!scrollingInfo.directionObj;
|
|
38
39
|
if (distances === null) {
|
|
39
|
-
resetScrolling();
|
|
40
|
+
if (isAlreadyScrolling) resetScrolling();
|
|
40
41
|
return false;
|
|
41
42
|
}
|
|
42
|
-
const isAlreadyScrolling = !!scrollingInfo.directionObj;
|
|
43
43
|
let [scrollingVertically, scrollingHorizontally] = [false, false];
|
|
44
44
|
// vertical
|
|
45
45
|
if (elementToScroll.scrollHeight > elementToScroll.clientHeight) {
|
package/src/pointerAction.js
CHANGED
|
@@ -58,6 +58,7 @@ let finalizingPreviousDrag = false;
|
|
|
58
58
|
let unlockOriginDzMinDimensions;
|
|
59
59
|
let isDraggedOutsideOfAnyDz = false;
|
|
60
60
|
let scheduledForRemovalAfterDrop = [];
|
|
61
|
+
let multiScroller;
|
|
61
62
|
|
|
62
63
|
// a map from type to a set of drop-zones
|
|
63
64
|
const typeToDropZones = new Map();
|
|
@@ -100,7 +101,7 @@ function watchDraggedElement() {
|
|
|
100
101
|
// it is important that we don't have an interval that is faster than the flip duration because it can cause elements to jump bach and forth
|
|
101
102
|
const setIntervalMs = Math.max(...Array.from(dropZones.keys()).map(dz => dzToConfig.get(dz).dropAnimationDurationMs));
|
|
102
103
|
const observationIntervalMs = setIntervalMs === 0 ? DISABLED_OBSERVATION_INTERVAL_MS : Math.max(setIntervalMs, MIN_OBSERVATION_INTERVAL_MS); // if setIntervalMs is 0 it goes to 20, otherwise it is max between it and min observation.
|
|
103
|
-
|
|
104
|
+
multiScroller = createMultiScroller(dropZones, () => currentMousePosition);
|
|
104
105
|
observe(draggedEl, dropZones, observationIntervalMs * 1.07, multiScroller);
|
|
105
106
|
}
|
|
106
107
|
function unWatchDraggedElement() {
|
|
@@ -112,6 +113,8 @@ function unWatchDraggedElement() {
|
|
|
112
113
|
dz.removeEventListener(DRAGGED_OVER_INDEX_EVENT_NAME, handleDraggedIsOverIndex);
|
|
113
114
|
}
|
|
114
115
|
window.removeEventListener(DRAGGED_LEFT_DOCUMENT_EVENT_NAME, handleDrop);
|
|
116
|
+
multiScroller.destroy();
|
|
117
|
+
multiScroller = undefined;
|
|
115
118
|
unobserve();
|
|
116
119
|
}
|
|
117
120
|
|