@rpg-engine/long-bow 0.7.51 → 0.7.52
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 +67 -13
- 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 +67 -13
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Item/Inventory/ItemSlot.tsx +83 -12
|
@@ -27936,6 +27936,12 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
27936
27936
|
var _useState4 = React.useState([]),
|
|
27937
27937
|
contextActions = _useState4[0],
|
|
27938
27938
|
setContextActions = _useState4[1];
|
|
27939
|
+
var _useState5 = React.useState(null),
|
|
27940
|
+
touchStartTime = _useState5[0],
|
|
27941
|
+
setTouchStartTime = _useState5[1];
|
|
27942
|
+
var _useState6 = React.useState(null),
|
|
27943
|
+
touchStartPosition = _useState6[0],
|
|
27944
|
+
setTouchStartPosition = _useState6[1];
|
|
27939
27945
|
React.useEffect(function () {
|
|
27940
27946
|
setDragState(function (prev) {
|
|
27941
27947
|
return _extends({}, prev, {
|
|
@@ -28018,6 +28024,27 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
28018
28024
|
// to prevent the item from being dragged again
|
|
28019
28025
|
target.classList.remove('react-draggable-dragging');
|
|
28020
28026
|
var isTouch = e.type.startsWith('touch');
|
|
28027
|
+
if (isTouch) {
|
|
28028
|
+
var touchEvent = e;
|
|
28029
|
+
var touch = touchEvent.changedTouches[0];
|
|
28030
|
+
var touchEndTime = new Date().getTime();
|
|
28031
|
+
var touchDuration = touchStartTime ? touchEndTime - touchStartTime : 0;
|
|
28032
|
+
// Check if it's a short tap (less than 200ms) and hasn't moved much
|
|
28033
|
+
var isShortTap = touchDuration < 200;
|
|
28034
|
+
var hasMovedSignificantly = touchStartPosition && (Math.abs(touch.clientX - touchStartPosition.x) > 10 || Math.abs(touch.clientY - touchStartPosition.y) > 10);
|
|
28035
|
+
if (isShortTap && !hasMovedSignificantly) {
|
|
28036
|
+
// Handle as a tap/click
|
|
28037
|
+
if (item) {
|
|
28038
|
+
setTooltipState(function (prev) {
|
|
28039
|
+
return _extends({}, prev, {
|
|
28040
|
+
mobileVisible: true
|
|
28041
|
+
});
|
|
28042
|
+
});
|
|
28043
|
+
onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28044
|
+
}
|
|
28045
|
+
return;
|
|
28046
|
+
}
|
|
28047
|
+
}
|
|
28021
28048
|
// Threshold for considering a tap/click as a drag
|
|
28022
28049
|
var dragThreshold = 5; // pixels
|
|
28023
28050
|
var isDrag = Math.abs(data.x) > dragThreshold || Math.abs(data.y) > dragThreshold;
|
|
@@ -28134,6 +28161,43 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
28134
28161
|
setDraggingItem(item);
|
|
28135
28162
|
}
|
|
28136
28163
|
};
|
|
28164
|
+
var onTouchStart = function onTouchStart(e) {
|
|
28165
|
+
setTouchStartTime(new Date().getTime());
|
|
28166
|
+
setTouchStartPosition({
|
|
28167
|
+
x: e.touches[0].clientX,
|
|
28168
|
+
y: e.touches[0].clientY
|
|
28169
|
+
});
|
|
28170
|
+
};
|
|
28171
|
+
var onTouchEnd = function onTouchEnd(e) {
|
|
28172
|
+
// Prevent default to stop potential unwanted behaviors
|
|
28173
|
+
e.preventDefault();
|
|
28174
|
+
var touch = e.changedTouches[0];
|
|
28175
|
+
var touchEndTime = new Date().getTime();
|
|
28176
|
+
var touchDuration = touchStartTime ? touchEndTime - touchStartTime : 0;
|
|
28177
|
+
// Check if it's a short tap (less than 200ms) and hasn't moved much
|
|
28178
|
+
var isShortTap = touchDuration < 200;
|
|
28179
|
+
var hasMovedSignificantly = touchStartPosition && (Math.abs(touch.clientX - touchStartPosition.x) > 10 || Math.abs(touch.clientY - touchStartPosition.y) > 10);
|
|
28180
|
+
if (isShortTap && !hasMovedSignificantly) {
|
|
28181
|
+
// Handle as a tap/click
|
|
28182
|
+
if (item) {
|
|
28183
|
+
setTooltipState(function (prev) {
|
|
28184
|
+
return _extends({}, prev, {
|
|
28185
|
+
mobileVisible: true
|
|
28186
|
+
});
|
|
28187
|
+
});
|
|
28188
|
+
onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28189
|
+
}
|
|
28190
|
+
} else {
|
|
28191
|
+
var _document$elementFrom;
|
|
28192
|
+
// Handle as a drag end
|
|
28193
|
+
var simulatedEvent = new MouseEvent('mouseup', {
|
|
28194
|
+
clientX: touch.clientX,
|
|
28195
|
+
clientY: touch.clientY,
|
|
28196
|
+
bubbles: true
|
|
28197
|
+
});
|
|
28198
|
+
(_document$elementFrom = document.elementFromPoint(touch.clientX, touch.clientY)) == null ? void 0 : _document$elementFrom.dispatchEvent(simulatedEvent);
|
|
28199
|
+
}
|
|
28200
|
+
};
|
|
28137
28201
|
var bounds = getContainerBounds();
|
|
28138
28202
|
return React__default.createElement(Container$b, {
|
|
28139
28203
|
isDraggingItem: !!draggingItem,
|
|
@@ -28145,22 +28209,12 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
28145
28209
|
onPlaceDrop(data, slotIndex, containerType);
|
|
28146
28210
|
}
|
|
28147
28211
|
},
|
|
28148
|
-
onTouchEnd: function onTouchEnd(e) {
|
|
28149
|
-
var _document$elementFrom;
|
|
28150
|
-
var _e$changedTouches$ = e.changedTouches[0],
|
|
28151
|
-
clientX = _e$changedTouches$.clientX,
|
|
28152
|
-
clientY = _e$changedTouches$.clientY;
|
|
28153
|
-
var simulatedEvent = new MouseEvent('mouseup', {
|
|
28154
|
-
clientX: clientX,
|
|
28155
|
-
clientY: clientY,
|
|
28156
|
-
bubbles: true
|
|
28157
|
-
});
|
|
28158
|
-
(_document$elementFrom = document.elementFromPoint(clientX, clientY)) == null ? void 0 : _document$elementFrom.dispatchEvent(simulatedEvent);
|
|
28159
|
-
},
|
|
28160
28212
|
onPointerDown: onDragStart !== undefined && onDragEnd !== undefined ? undefined : function () {
|
|
28161
28213
|
if (item) onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28162
28214
|
},
|
|
28163
|
-
isSelectingShortcut: isSelectingShortcut && ((item == null ? void 0 : item.type) === shared.ItemType.Consumable || (item == null ? void 0 : item.type) === shared.ItemType.Tool || (item == null ? void 0 : item.subType) === shared.ItemSubType.Seed)
|
|
28215
|
+
isSelectingShortcut: isSelectingShortcut && ((item == null ? void 0 : item.type) === shared.ItemType.Consumable || (item == null ? void 0 : item.type) === shared.ItemType.Tool || (item == null ? void 0 : item.subType) === shared.ItemSubType.Seed),
|
|
28216
|
+
onTouchStart: onTouchStart,
|
|
28217
|
+
onTouchEnd: onTouchEnd
|
|
28164
28218
|
}, React__default.createElement(Draggable, {
|
|
28165
28219
|
axis: isSelectingShortcut ? 'none' : 'both',
|
|
28166
28220
|
defaultClassName: item ? 'draggable' : 'empty-slot',
|