@rpg-engine/long-bow 0.7.81 → 0.7.82
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/hooks/useTouchTarget.d.ts +5 -0
- package/dist/long-bow.cjs.development.js +21 -0
- 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 +22 -1
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Item/Inventory/ItemSlot.tsx +9 -1
- package/src/hooks/useTouchTarget.ts +38 -0
package/dist/long-bow.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useEffect, Component, useRef, useContext, createContext,
|
|
1
|
+
import React, { useState, useEffect, Component, useRef, useCallback, useContext, createContext, useMemo, Fragment } from 'react';
|
|
2
2
|
import styled, { css, keyframes } from 'styled-components';
|
|
3
3
|
import { BeatLoader } from 'react-spinners';
|
|
4
4
|
import { v4 } from 'uuid';
|
|
@@ -27371,6 +27371,23 @@ var Container$8 = /*#__PURE__*/styled.div.withConfig({
|
|
|
27371
27371
|
componentId: "sc-dgmp04-0"
|
|
27372
27372
|
})(["position:static !important;"]);
|
|
27373
27373
|
|
|
27374
|
+
function useTouchTarget() {
|
|
27375
|
+
var getTouchTarget = useCallback(function (e) {
|
|
27376
|
+
// Check if it's a touch event
|
|
27377
|
+
if ('changedTouches' in e || 'touches' in e) {
|
|
27378
|
+
var _touchEvent$changedTo, _touchEvent$touches;
|
|
27379
|
+
var touchEvent = e;
|
|
27380
|
+
var touch = ((_touchEvent$changedTo = touchEvent.changedTouches) == null ? void 0 : _touchEvent$changedTo[0]) || ((_touchEvent$touches = touchEvent.touches) == null ? void 0 : _touchEvent$touches[0]);
|
|
27381
|
+
if (touch) {
|
|
27382
|
+
return document.elementFromPoint(touch.clientX, touch.clientY);
|
|
27383
|
+
}
|
|
27384
|
+
}
|
|
27385
|
+
// If it's not a touch event or touch is not available, fallback to target
|
|
27386
|
+
return e.target || document.body;
|
|
27387
|
+
}, []);
|
|
27388
|
+
return getTouchTarget;
|
|
27389
|
+
}
|
|
27390
|
+
|
|
27374
27391
|
var rarityColor = function rarityColor(item) {
|
|
27375
27392
|
switch (item == null ? void 0 : item.rarity) {
|
|
27376
27393
|
case ItemRarities.Uncommon:
|
|
@@ -27814,6 +27831,7 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
|
|
|
27814
27831
|
detailsState = _useItemSlotDetails.detailsState,
|
|
27815
27832
|
updateDetailsState = _useItemSlotDetails.updateDetailsState,
|
|
27816
27833
|
setContextActions = _useItemSlotDetails.setContextActions;
|
|
27834
|
+
var getTouchTarget = useTouchTarget();
|
|
27817
27835
|
var isContextMenuVisible = detailsState.isContextMenuVisible,
|
|
27818
27836
|
clearDetailsState = detailsState.clearDetailsState,
|
|
27819
27837
|
clearContextActions = detailsState.clearContextActions;
|
|
@@ -27870,6 +27888,9 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
|
|
|
27870
27888
|
item: null
|
|
27871
27889
|
});
|
|
27872
27890
|
var target = e.target;
|
|
27891
|
+
if (isMobile()) {
|
|
27892
|
+
target = getTouchTarget(e);
|
|
27893
|
+
}
|
|
27873
27894
|
handleShortcutSetter(target);
|
|
27874
27895
|
removeDraggingClass(target);
|
|
27875
27896
|
var shouldHandleDraggedItemResult = shouldHandleDraggedItem();
|