@rpg-engine/long-bow 0.7.48 → 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/dist/long-bow.cjs.development.js +9 -7
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +9 -7
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Item/Inventory/ItemSlot.tsx +8 -6
package/package.json
CHANGED
|
@@ -142,7 +142,7 @@ export const ItemSlot = React.memo(
|
|
|
142
142
|
const [contextActions, setContextActions] = useState<IContextMenuItem[]>(
|
|
143
143
|
[]
|
|
144
144
|
);
|
|
145
|
-
const [
|
|
145
|
+
const [dragStartTime, setDragStartTime] = useState<number | null>(null);
|
|
146
146
|
|
|
147
147
|
useEffect(() => {
|
|
148
148
|
setDragState(prev => ({
|
|
@@ -201,7 +201,6 @@ export const ItemSlot = React.memo(
|
|
|
201
201
|
|
|
202
202
|
const onDraggableStop: DraggableEventHandler = (e, data) => {
|
|
203
203
|
setDraggingItem(null);
|
|
204
|
-
setIsDragStarted(false);
|
|
205
204
|
|
|
206
205
|
const target = e.target as HTMLElement;
|
|
207
206
|
if (!target) return;
|
|
@@ -217,6 +216,9 @@ export const ItemSlot = React.memo(
|
|
|
217
216
|
// to prevent the item from being dragged again
|
|
218
217
|
target.classList.remove('react-draggable-dragging');
|
|
219
218
|
|
|
219
|
+
const dragEndTime = Date.now();
|
|
220
|
+
const dragDuration = dragStartTime ? dragEndTime - dragStartTime : 0;
|
|
221
|
+
|
|
220
222
|
if (dragState.wasDragged && item && !isSelectingShortcut) {
|
|
221
223
|
//@ts-ignore
|
|
222
224
|
const classes: string[] = Array.from(e.target?.classList);
|
|
@@ -268,13 +270,13 @@ export const ItemSlot = React.memo(
|
|
|
268
270
|
}));
|
|
269
271
|
}
|
|
270
272
|
}, 50);
|
|
271
|
-
} else if (item &&
|
|
273
|
+
} else if (item && dragDuration < 200) {
|
|
274
|
+
// Consider it a click if drag duration is less than 200ms
|
|
272
275
|
let isTouch = false;
|
|
273
276
|
if (
|
|
274
277
|
!isContextMenuDisabled &&
|
|
275
278
|
e.type === 'touchend' &&
|
|
276
|
-
!isSelectingShortcut
|
|
277
|
-
!dragState.wasDragged
|
|
279
|
+
!isSelectingShortcut
|
|
278
280
|
) {
|
|
279
281
|
isTouch = true;
|
|
280
282
|
setTooltipState(prev => ({ ...prev, mobileVisible: true }));
|
|
@@ -313,7 +315,7 @@ export const ItemSlot = React.memo(
|
|
|
313
315
|
return;
|
|
314
316
|
}
|
|
315
317
|
|
|
316
|
-
|
|
318
|
+
setDragStartTime(Date.now());
|
|
317
319
|
|
|
318
320
|
if (onDragStart && containerType) {
|
|
319
321
|
onDragStart(item, slotIndex, containerType);
|