svelte-dnd-action 0.9.59 → 0.9.61

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 CHANGED
@@ -1752,7 +1752,12 @@
1752
1752
 
1753
1753
  // dragging initiated by touch events prevents onclick from initially firing
1754
1754
  if (e.type === "touchend") {
1755
- e.target.click();
1755
+ var clickEvent = new Event("click", {
1756
+ bubbles: true,
1757
+ cancelable: true
1758
+ });
1759
+ // doing it this way instead of calling .click() because that doesn't work for SVG elements
1760
+ e.target.dispatchEvent(clickEvent);
1756
1761
  }
1757
1762
  }
1758
1763
  function handleMouseMoveMaybeDragStart(e) {
@@ -2690,10 +2695,19 @@
2690
2695
  // preventing default to prevent lag on touch devices (because of the browser checking for screen scrolling)
2691
2696
  e.preventDefault();
2692
2697
  isItemsDragDisabled.set(false);
2698
+
2699
+ // Reset the startDrag/isItemsDragDisabled if the user releases the mouse/touch without initiating a drag
2700
+ window.addEventListener("mouseup", resetStartDrag);
2701
+ window.addEventListener("touchend", resetStartDrag);
2693
2702
  }
2694
2703
  function handleKeyDown(e) {
2695
2704
  if (e.key === "Enter" || e.key === " ") isItemsDragDisabled.set(false);
2696
2705
  }
2706
+ function resetStartDrag() {
2707
+ isItemsDragDisabled.set(true);
2708
+ window.removeEventListener("mouseup", resetStartDrag);
2709
+ window.removeEventListener("touchend", resetStartDrag);
2710
+ }
2697
2711
  isItemsDragDisabled.subscribe(function (disabled) {
2698
2712
  handle.tabIndex = disabled ? 0 : -1;
2699
2713
  handle.style.cursor = disabled ? "grab" : "grabbing";
package/dist/index.mjs CHANGED
@@ -1746,7 +1746,12 @@ function dndzone$2(node, options) {
1746
1746
 
1747
1747
  // dragging initiated by touch events prevents onclick from initially firing
1748
1748
  if (e.type === "touchend") {
1749
- e.target.click();
1749
+ var clickEvent = new Event("click", {
1750
+ bubbles: true,
1751
+ cancelable: true
1752
+ });
1753
+ // doing it this way instead of calling .click() because that doesn't work for SVG elements
1754
+ e.target.dispatchEvent(clickEvent);
1750
1755
  }
1751
1756
  }
1752
1757
  function handleMouseMoveMaybeDragStart(e) {
@@ -2684,10 +2689,19 @@ function dragHandle(handle) {
2684
2689
  // preventing default to prevent lag on touch devices (because of the browser checking for screen scrolling)
2685
2690
  e.preventDefault();
2686
2691
  isItemsDragDisabled.set(false);
2692
+
2693
+ // Reset the startDrag/isItemsDragDisabled if the user releases the mouse/touch without initiating a drag
2694
+ window.addEventListener("mouseup", resetStartDrag);
2695
+ window.addEventListener("touchend", resetStartDrag);
2687
2696
  }
2688
2697
  function handleKeyDown(e) {
2689
2698
  if (e.key === "Enter" || e.key === " ") isItemsDragDisabled.set(false);
2690
2699
  }
2700
+ function resetStartDrag() {
2701
+ isItemsDragDisabled.set(true);
2702
+ window.removeEventListener("mouseup", resetStartDrag);
2703
+ window.removeEventListener("touchend", resetStartDrag);
2704
+ }
2691
2705
  isItemsDragDisabled.subscribe(function (disabled) {
2692
2706
  handle.tabIndex = disabled ? 0 : -1;
2693
2707
  handle.style.cursor = disabled ? "grab" : "grabbing";
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.59",
4
+ "version": "0.9.61",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/isaacHagoel/svelte-dnd-action.git"
@@ -374,7 +374,12 @@ export function dndzone(node, options) {
374
374
 
375
375
  // dragging initiated by touch events prevents onclick from initially firing
376
376
  if (e.type === "touchend") {
377
- e.target.click();
377
+ const clickEvent = new Event("click", {
378
+ bubbles: true,
379
+ cancelable: true
380
+ });
381
+ // doing it this way instead of calling .click() because that doesn't work for SVG elements
382
+ e.target.dispatchEvent(clickEvent);
378
383
  }
379
384
  }
380
385
 
@@ -84,11 +84,22 @@ export function dragHandle(handle) {
84
84
  // preventing default to prevent lag on touch devices (because of the browser checking for screen scrolling)
85
85
  e.preventDefault();
86
86
  isItemsDragDisabled.set(false);
87
+
88
+ // Reset the startDrag/isItemsDragDisabled if the user releases the mouse/touch without initiating a drag
89
+ window.addEventListener("mouseup", resetStartDrag);
90
+ window.addEventListener("touchend", resetStartDrag);
87
91
  }
92
+
88
93
  function handleKeyDown(e) {
89
94
  if (e.key === "Enter" || e.key === " ") isItemsDragDisabled.set(false);
90
95
  }
91
96
 
97
+ function resetStartDrag() {
98
+ isItemsDragDisabled.set(true);
99
+ window.removeEventListener("mouseup", resetStartDrag);
100
+ window.removeEventListener("touchend", resetStartDrag);
101
+ }
102
+
92
103
  isItemsDragDisabled.subscribe(disabled => {
93
104
  handle.tabIndex = disabled ? 0 : -1;
94
105
  handle.style.cursor = disabled ? "grab" : "grabbing";