@rpg-engine/long-bow 0.7.49 → 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.49",
3
+ "version": "0.7.51",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -215,6 +215,13 @@ export const ItemSlot = React.memo(
215
215
  // to prevent the item from being dragged again
216
216
  target.classList.remove('react-draggable-dragging');
217
217
 
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;
224
+
218
225
  if (dragState.wasDragged && item && !isSelectingShortcut) {
219
226
  //@ts-ignore
220
227
  const classes: string[] = Array.from(e.target?.classList);
@@ -267,21 +274,15 @@ export const ItemSlot = React.memo(
267
274
  }
268
275
  }, 50);
269
276
  } else if (item) {
270
- let isTouch = false;
271
- if (
277
+ if (isTouch && !isDrag) {
278
+ setTooltipState(prev => ({
279
+ ...prev,
280
+ mobileVisible: true,
281
+ }));
282
+ } else if (
283
+ !isTouch &&
272
284
  !isContextMenuDisabled &&
273
- e.type === 'touchend' &&
274
285
  !isSelectingShortcut
275
- ) {
276
- isTouch = true;
277
- setTooltipState(prev => ({ ...prev, mobileVisible: true }));
278
- }
279
-
280
- if (
281
- !isContextMenuDisabled &&
282
- !isSelectingShortcut &&
283
- !isTouch &&
284
- !dragState.wasDragged
285
286
  ) {
286
287
  setContextMenuState(prev => ({
287
288
  ...prev,
@@ -301,8 +302,14 @@ export const ItemSlot = React.memo(
301
302
  }
302
303
  }
303
304
 
304
- onPointerDown(item.type, containerType ?? null, item);
305
+ if (!isDrag || !isTouch) {
306
+ console.log('Calling onPointerDown');
307
+ onPointerDown(item.type, containerType ?? null, item);
308
+ }
305
309
  }
310
+
311
+ setDragState(prev => ({ ...prev, wasDragged: false }));
312
+ console.log('Final dragState:', dragState);
306
313
  };
307
314
 
308
315
  const onDraggableStart: DraggableEventHandler = () => {