@rpg-engine/long-bow 0.7.50 → 0.7.51

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.50",
3
+ "version": "0.7.51",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -142,7 +142,6 @@ export const ItemSlot = React.memo(
142
142
  const [contextActions, setContextActions] = useState<IContextMenuItem[]>(
143
143
  []
144
144
  );
145
- const [dragStartTime, setDragStartTime] = useState<number | null>(null);
146
145
 
147
146
  useEffect(() => {
148
147
  setDragState(prev => ({
@@ -216,8 +215,12 @@ export const ItemSlot = React.memo(
216
215
  // to prevent the item from being dragged again
217
216
  target.classList.remove('react-draggable-dragging');
218
217
 
219
- const dragEndTime = Date.now();
220
- const dragDuration = dragStartTime ? dragEndTime - dragStartTime : 0;
218
+ const isTouch = e.type.startsWith('touch');
219
+
220
+ // Threshold for considering a tap/click as a drag
221
+ const dragThreshold = 5; // pixels
222
+ const isDrag =
223
+ Math.abs(data.x) > dragThreshold || Math.abs(data.y) > dragThreshold;
221
224
 
222
225
  if (dragState.wasDragged && item && !isSelectingShortcut) {
223
226
  //@ts-ignore
@@ -270,23 +273,16 @@ export const ItemSlot = React.memo(
270
273
  }));
271
274
  }
272
275
  }, 50);
273
- } else if (item && dragDuration < 200) {
274
- // Consider it a click if drag duration is less than 200ms
275
- let isTouch = false;
276
- if (
276
+ } else if (item) {
277
+ if (isTouch && !isDrag) {
278
+ setTooltipState(prev => ({
279
+ ...prev,
280
+ mobileVisible: true,
281
+ }));
282
+ } else if (
283
+ !isTouch &&
277
284
  !isContextMenuDisabled &&
278
- e.type === 'touchend' &&
279
285
  !isSelectingShortcut
280
- ) {
281
- isTouch = true;
282
- setTooltipState(prev => ({ ...prev, mobileVisible: true }));
283
- }
284
-
285
- if (
286
- !isContextMenuDisabled &&
287
- !isSelectingShortcut &&
288
- !isTouch &&
289
- !dragState.wasDragged
290
286
  ) {
291
287
  setContextMenuState(prev => ({
292
288
  ...prev,
@@ -306,8 +302,14 @@ export const ItemSlot = React.memo(
306
302
  }
307
303
  }
308
304
 
309
- onPointerDown(item.type, containerType ?? null, item);
305
+ if (!isDrag || !isTouch) {
306
+ console.log('Calling onPointerDown');
307
+ onPointerDown(item.type, containerType ?? null, item);
308
+ }
310
309
  }
310
+
311
+ setDragState(prev => ({ ...prev, wasDragged: false }));
312
+ console.log('Final dragState:', dragState);
311
313
  };
312
314
 
313
315
  const onDraggableStart: DraggableEventHandler = () => {
@@ -315,8 +317,6 @@ export const ItemSlot = React.memo(
315
317
  return;
316
318
  }
317
319
 
318
- setDragStartTime(Date.now());
319
-
320
320
  if (onDragStart && containerType) {
321
321
  onDragStart(item, slotIndex, containerType);
322
322
  }