svelte-dnd-action 0.9.13 → 0.9.14
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/dist/index.js +14 -1
- package/dist/index.mjs +14 -1
- package/package.json +1 -1
- package/src/helpers/listUtil.js +9 -0
- package/src/helpers/observer.js +2 -1
- package/src/helpers/windowScroller.js +3 -1
package/dist/index.js
CHANGED
|
@@ -599,6 +599,17 @@
|
|
|
599
599
|
dzToShadowIndexToRect = new Map();
|
|
600
600
|
}
|
|
601
601
|
resetIndexesCache();
|
|
602
|
+
/**
|
|
603
|
+
* Resets the cache that allows for smarter "would be index" resolution for a specific dropzone, should be called after the zone was scrolled
|
|
604
|
+
* @param {HTMLElement} dz
|
|
605
|
+
*/
|
|
606
|
+
|
|
607
|
+
function resetIndexesCacheForDz(dz) {
|
|
608
|
+
printDebug(function () {
|
|
609
|
+
return "resetting indexes cache for dz";
|
|
610
|
+
});
|
|
611
|
+
dzToShadowIndexToRect["delete"](dz);
|
|
612
|
+
}
|
|
602
613
|
/**
|
|
603
614
|
* Caches the coordinates of the shadow element when it's in a certain index in a certain dropzone.
|
|
604
615
|
* Helpful in order to determine "would be index" more effectively
|
|
@@ -931,6 +942,7 @@
|
|
|
931
942
|
try {
|
|
932
943
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
933
944
|
var dz = _step.value;
|
|
945
|
+
if (scrolled) resetIndexesCacheForDz(lastDropZoneFound);
|
|
934
946
|
var indexObj = findWouldBeIndex(draggedEl, dz);
|
|
935
947
|
|
|
936
948
|
if (indexObj === null) {
|
|
@@ -1008,7 +1020,8 @@
|
|
|
1008
1020
|
|
|
1009
1021
|
function loop() {
|
|
1010
1022
|
if (mousePosition) {
|
|
1011
|
-
scrollIfNeeded$1(mousePosition, document.documentElement);
|
|
1023
|
+
var scrolled = scrollIfNeeded$1(mousePosition, document.documentElement);
|
|
1024
|
+
if (scrolled) resetIndexesCache();
|
|
1012
1025
|
}
|
|
1013
1026
|
|
|
1014
1027
|
next$1 = window.setTimeout(loop, INTERVAL_MS$1);
|
package/dist/index.mjs
CHANGED
|
@@ -593,6 +593,17 @@ function resetIndexesCache() {
|
|
|
593
593
|
dzToShadowIndexToRect = new Map();
|
|
594
594
|
}
|
|
595
595
|
resetIndexesCache();
|
|
596
|
+
/**
|
|
597
|
+
* Resets the cache that allows for smarter "would be index" resolution for a specific dropzone, should be called after the zone was scrolled
|
|
598
|
+
* @param {HTMLElement} dz
|
|
599
|
+
*/
|
|
600
|
+
|
|
601
|
+
function resetIndexesCacheForDz(dz) {
|
|
602
|
+
printDebug(function () {
|
|
603
|
+
return "resetting indexes cache for dz";
|
|
604
|
+
});
|
|
605
|
+
dzToShadowIndexToRect["delete"](dz);
|
|
606
|
+
}
|
|
596
607
|
/**
|
|
597
608
|
* Caches the coordinates of the shadow element when it's in a certain index in a certain dropzone.
|
|
598
609
|
* Helpful in order to determine "would be index" more effectively
|
|
@@ -925,6 +936,7 @@ function observe(draggedEl, dropZones) {
|
|
|
925
936
|
try {
|
|
926
937
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
927
938
|
var dz = _step.value;
|
|
939
|
+
if (scrolled) resetIndexesCacheForDz(lastDropZoneFound);
|
|
928
940
|
var indexObj = findWouldBeIndex(draggedEl, dz);
|
|
929
941
|
|
|
930
942
|
if (indexObj === null) {
|
|
@@ -1002,7 +1014,8 @@ var next$1;
|
|
|
1002
1014
|
|
|
1003
1015
|
function loop() {
|
|
1004
1016
|
if (mousePosition) {
|
|
1005
|
-
scrollIfNeeded$1(mousePosition, document.documentElement);
|
|
1017
|
+
var scrolled = scrollIfNeeded$1(mousePosition, document.documentElement);
|
|
1018
|
+
if (scrolled) resetIndexesCache();
|
|
1006
1019
|
}
|
|
1007
1020
|
|
|
1008
1021
|
next$1 = window.setTimeout(loop, INTERVAL_MS$1);
|
package/package.json
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dist"
|
|
41
41
|
],
|
|
42
42
|
"description": "*An awesome drag and drop library for Svelte 3 (not using the browser's built-in dnd, thanks god): Rich animations, nested containers, touch support and more *",
|
|
43
|
-
"version": "0.9.
|
|
43
|
+
"version": "0.9.14",
|
|
44
44
|
"repository": {
|
|
45
45
|
"type": "git",
|
|
46
46
|
"url": "git+https://github.com/isaacHagoel/svelte-dnd-action.git"
|
package/src/helpers/listUtil.js
CHANGED
|
@@ -12,6 +12,15 @@ export function resetIndexesCache() {
|
|
|
12
12
|
}
|
|
13
13
|
resetIndexesCache();
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Resets the cache that allows for smarter "would be index" resolution for a specific dropzone, should be called after the zone was scrolled
|
|
17
|
+
* @param {HTMLElement} dz
|
|
18
|
+
*/
|
|
19
|
+
export function resetIndexesCacheForDz(dz) {
|
|
20
|
+
printDebug(() => "resetting indexes cache for dz");
|
|
21
|
+
dzToShadowIndexToRect.delete(dz);
|
|
22
|
+
}
|
|
23
|
+
|
|
15
24
|
/**
|
|
16
25
|
* Caches the coordinates of the shadow element when it's in a certain index in a certain dropzone.
|
|
17
26
|
* Helpful in order to determine "would be index" more effectively
|
package/src/helpers/observer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {findWouldBeIndex, resetIndexesCache} from "./listUtil";
|
|
1
|
+
import {findWouldBeIndex, resetIndexesCache, resetIndexesCacheForDz} from "./listUtil";
|
|
2
2
|
import {findCenterOfElement, isElementOffDocument} from "./intersection";
|
|
3
3
|
import {
|
|
4
4
|
dispatchDraggedElementEnteredContainer,
|
|
@@ -57,6 +57,7 @@ export function observe(draggedEl, dropZones, intervalMs = INTERVAL_MS) {
|
|
|
57
57
|
// this is a simple algorithm, potential improvement: first look at lastDropZoneFound
|
|
58
58
|
let isDraggedInADropZone = false;
|
|
59
59
|
for (const dz of dropZonesFromDeepToShallow) {
|
|
60
|
+
if (scrolled) resetIndexesCacheForDz(lastDropZoneFound);
|
|
60
61
|
const indexObj = findWouldBeIndex(draggedEl, dz);
|
|
61
62
|
if (indexObj === null) {
|
|
62
63
|
// it is not inside
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {makeScroller} from "./scroller";
|
|
2
2
|
import {printDebug} from "../constants";
|
|
3
|
+
import {resetIndexesCache} from "./listUtil";
|
|
3
4
|
|
|
4
5
|
const INTERVAL_MS = 300;
|
|
5
6
|
let mousePosition;
|
|
@@ -18,7 +19,8 @@ let next;
|
|
|
18
19
|
|
|
19
20
|
function loop() {
|
|
20
21
|
if (mousePosition) {
|
|
21
|
-
scrollIfNeeded(mousePosition, document.documentElement);
|
|
22
|
+
const scrolled = scrollIfNeeded(mousePosition, document.documentElement);
|
|
23
|
+
if (scrolled) resetIndexesCache();
|
|
22
24
|
}
|
|
23
25
|
next = window.setTimeout(loop, INTERVAL_MS);
|
|
24
26
|
}
|