@rpg-engine/long-bow 0.7.50 → 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 +83 -26
- 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 +83 -26
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Item/Inventory/ItemSlot.tsx +104 -33
|
@@ -27937,8 +27937,11 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
27937
27937
|
contextActions = _useState4[0],
|
|
27938
27938
|
setContextActions = _useState4[1];
|
|
27939
27939
|
var _useState5 = React.useState(null),
|
|
27940
|
-
|
|
27941
|
-
|
|
27940
|
+
touchStartTime = _useState5[0],
|
|
27941
|
+
setTouchStartTime = _useState5[1];
|
|
27942
|
+
var _useState6 = React.useState(null),
|
|
27943
|
+
touchStartPosition = _useState6[0],
|
|
27944
|
+
setTouchStartPosition = _useState6[1];
|
|
27942
27945
|
React.useEffect(function () {
|
|
27943
27946
|
setDragState(function (prev) {
|
|
27944
27947
|
return _extends({}, prev, {
|
|
@@ -28020,8 +28023,31 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
28020
28023
|
// remove the class react-draggable-dragging from the element
|
|
28021
28024
|
// to prevent the item from being dragged again
|
|
28022
28025
|
target.classList.remove('react-draggable-dragging');
|
|
28023
|
-
var
|
|
28024
|
-
|
|
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
|
+
}
|
|
28048
|
+
// Threshold for considering a tap/click as a drag
|
|
28049
|
+
var dragThreshold = 5; // pixels
|
|
28050
|
+
var isDrag = Math.abs(data.x) > dragThreshold || Math.abs(data.y) > dragThreshold;
|
|
28025
28051
|
if (dragState.wasDragged && item && !isSelectingShortcut) {
|
|
28026
28052
|
var _e$target;
|
|
28027
28053
|
//@ts-ignore
|
|
@@ -28077,18 +28103,14 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
28077
28103
|
});
|
|
28078
28104
|
}
|
|
28079
28105
|
}, 50);
|
|
28080
|
-
} else if (item
|
|
28081
|
-
|
|
28082
|
-
var isTouch = false;
|
|
28083
|
-
if (!isContextMenuDisabled && e.type === 'touchend' && !isSelectingShortcut) {
|
|
28084
|
-
isTouch = true;
|
|
28106
|
+
} else if (item) {
|
|
28107
|
+
if (isTouch && !isDrag) {
|
|
28085
28108
|
setTooltipState(function (prev) {
|
|
28086
28109
|
return _extends({}, prev, {
|
|
28087
28110
|
mobileVisible: true
|
|
28088
28111
|
});
|
|
28089
28112
|
});
|
|
28090
|
-
}
|
|
28091
|
-
if (!isContextMenuDisabled && !isSelectingShortcut && !isTouch && !dragState.wasDragged) {
|
|
28113
|
+
} else if (!isTouch && !isContextMenuDisabled && !isSelectingShortcut) {
|
|
28092
28114
|
setContextMenuState(function (prev) {
|
|
28093
28115
|
return _extends({}, prev, {
|
|
28094
28116
|
visible: !contextMenuState.visible
|
|
@@ -28106,14 +28128,22 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
28106
28128
|
});
|
|
28107
28129
|
}
|
|
28108
28130
|
}
|
|
28109
|
-
|
|
28131
|
+
if (!isDrag || !isTouch) {
|
|
28132
|
+
console.log('Calling onPointerDown');
|
|
28133
|
+
onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28134
|
+
}
|
|
28110
28135
|
}
|
|
28136
|
+
setDragState(function (prev) {
|
|
28137
|
+
return _extends({}, prev, {
|
|
28138
|
+
wasDragged: false
|
|
28139
|
+
});
|
|
28140
|
+
});
|
|
28141
|
+
console.log('Final dragState:', dragState);
|
|
28111
28142
|
};
|
|
28112
28143
|
var onDraggableStart = function onDraggableStart() {
|
|
28113
28144
|
if (!item || isSelectingShortcut) {
|
|
28114
28145
|
return;
|
|
28115
28146
|
}
|
|
28116
|
-
setDragStartTime(Date.now());
|
|
28117
28147
|
if (onDragStart && containerType) {
|
|
28118
28148
|
onDragStart(item, slotIndex, containerType);
|
|
28119
28149
|
}
|
|
@@ -28131,6 +28161,43 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
28131
28161
|
setDraggingItem(item);
|
|
28132
28162
|
}
|
|
28133
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
|
+
};
|
|
28134
28201
|
var bounds = getContainerBounds();
|
|
28135
28202
|
return React__default.createElement(Container$b, {
|
|
28136
28203
|
isDraggingItem: !!draggingItem,
|
|
@@ -28142,22 +28209,12 @@ var ItemSlot = /*#__PURE__*/React__default.memo( /*#__PURE__*/mobxReactLite.obse
|
|
|
28142
28209
|
onPlaceDrop(data, slotIndex, containerType);
|
|
28143
28210
|
}
|
|
28144
28211
|
},
|
|
28145
|
-
onTouchEnd: function onTouchEnd(e) {
|
|
28146
|
-
var _document$elementFrom;
|
|
28147
|
-
var _e$changedTouches$ = e.changedTouches[0],
|
|
28148
|
-
clientX = _e$changedTouches$.clientX,
|
|
28149
|
-
clientY = _e$changedTouches$.clientY;
|
|
28150
|
-
var simulatedEvent = new MouseEvent('mouseup', {
|
|
28151
|
-
clientX: clientX,
|
|
28152
|
-
clientY: clientY,
|
|
28153
|
-
bubbles: true
|
|
28154
|
-
});
|
|
28155
|
-
(_document$elementFrom = document.elementFromPoint(clientX, clientY)) == null ? void 0 : _document$elementFrom.dispatchEvent(simulatedEvent);
|
|
28156
|
-
},
|
|
28157
28212
|
onPointerDown: onDragStart !== undefined && onDragEnd !== undefined ? undefined : function () {
|
|
28158
28213
|
if (item) onPointerDown(item.type, containerType != null ? containerType : null, item);
|
|
28159
28214
|
},
|
|
28160
|
-
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
|
|
28161
28218
|
}, React__default.createElement(Draggable, {
|
|
28162
28219
|
axis: isSelectingShortcut ? 'none' : 'both',
|
|
28163
28220
|
defaultClassName: item ? 'draggable' : 'empty-slot',
|