@rpg-engine/long-bow 0.7.49 → 0.7.50

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.7.49",
3
+ "version": "0.7.50",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -142,6 +142,7 @@ export const ItemSlot = React.memo(
142
142
  const [contextActions, setContextActions] = useState<IContextMenuItem[]>(
143
143
  []
144
144
  );
145
+ const [dragStartTime, setDragStartTime] = useState<number | null>(null);
145
146
 
146
147
  useEffect(() => {
147
148
  setDragState(prev => ({
@@ -215,6 +216,9 @@ export const ItemSlot = React.memo(
215
216
  // to prevent the item from being dragged again
216
217
  target.classList.remove('react-draggable-dragging');
217
218
 
219
+ const dragEndTime = Date.now();
220
+ const dragDuration = dragStartTime ? dragEndTime - dragStartTime : 0;
221
+
218
222
  if (dragState.wasDragged && item && !isSelectingShortcut) {
219
223
  //@ts-ignore
220
224
  const classes: string[] = Array.from(e.target?.classList);
@@ -266,7 +270,8 @@ export const ItemSlot = React.memo(
266
270
  }));
267
271
  }
268
272
  }, 50);
269
- } else if (item) {
273
+ } else if (item && dragDuration < 200) {
274
+ // Consider it a click if drag duration is less than 200ms
270
275
  let isTouch = false;
271
276
  if (
272
277
  !isContextMenuDisabled &&
@@ -310,6 +315,8 @@ export const ItemSlot = React.memo(
310
315
  return;
311
316
  }
312
317
 
318
+ setDragStartTime(Date.now());
319
+
313
320
  if (onDragStart && containerType) {
314
321
  onDragStart(item, slotIndex, containerType);
315
322
  }