@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.
@@ -27930,6 +27930,12 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
27930
27930
  var _useState4 = useState([]),
27931
27931
  contextActions = _useState4[0],
27932
27932
  setContextActions = _useState4[1];
27933
+ var _useState5 = useState(null),
27934
+ touchStartTime = _useState5[0],
27935
+ setTouchStartTime = _useState5[1];
27936
+ var _useState6 = useState(null),
27937
+ touchStartPosition = _useState6[0],
27938
+ setTouchStartPosition = _useState6[1];
27933
27939
  useEffect(function () {
27934
27940
  setDragState(function (prev) {
27935
27941
  return _extends({}, prev, {
@@ -28012,6 +28018,27 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
28012
28018
  // to prevent the item from being dragged again
28013
28019
  target.classList.remove('react-draggable-dragging');
28014
28020
  var isTouch = e.type.startsWith('touch');
28021
+ if (isTouch) {
28022
+ var touchEvent = e;
28023
+ var touch = touchEvent.changedTouches[0];
28024
+ var touchEndTime = new Date().getTime();
28025
+ var touchDuration = touchStartTime ? touchEndTime - touchStartTime : 0;
28026
+ // Check if it's a short tap (less than 200ms) and hasn't moved much
28027
+ var isShortTap = touchDuration < 200;
28028
+ var hasMovedSignificantly = touchStartPosition && (Math.abs(touch.clientX - touchStartPosition.x) > 10 || Math.abs(touch.clientY - touchStartPosition.y) > 10);
28029
+ if (isShortTap && !hasMovedSignificantly) {
28030
+ // Handle as a tap/click
28031
+ if (item) {
28032
+ setTooltipState(function (prev) {
28033
+ return _extends({}, prev, {
28034
+ mobileVisible: true
28035
+ });
28036
+ });
28037
+ onPointerDown(item.type, containerType != null ? containerType : null, item);
28038
+ }
28039
+ return;
28040
+ }
28041
+ }
28015
28042
  // Threshold for considering a tap/click as a drag
28016
28043
  var dragThreshold = 5; // pixels
28017
28044
  var isDrag = Math.abs(data.x) > dragThreshold || Math.abs(data.y) > dragThreshold;
@@ -28128,6 +28155,43 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
28128
28155
  setDraggingItem(item);
28129
28156
  }
28130
28157
  };
28158
+ var onTouchStart = function onTouchStart(e) {
28159
+ setTouchStartTime(new Date().getTime());
28160
+ setTouchStartPosition({
28161
+ x: e.touches[0].clientX,
28162
+ y: e.touches[0].clientY
28163
+ });
28164
+ };
28165
+ var onTouchEnd = function onTouchEnd(e) {
28166
+ // Prevent default to stop potential unwanted behaviors
28167
+ e.preventDefault();
28168
+ var touch = e.changedTouches[0];
28169
+ var touchEndTime = new Date().getTime();
28170
+ var touchDuration = touchStartTime ? touchEndTime - touchStartTime : 0;
28171
+ // Check if it's a short tap (less than 200ms) and hasn't moved much
28172
+ var isShortTap = touchDuration < 200;
28173
+ var hasMovedSignificantly = touchStartPosition && (Math.abs(touch.clientX - touchStartPosition.x) > 10 || Math.abs(touch.clientY - touchStartPosition.y) > 10);
28174
+ if (isShortTap && !hasMovedSignificantly) {
28175
+ // Handle as a tap/click
28176
+ if (item) {
28177
+ setTooltipState(function (prev) {
28178
+ return _extends({}, prev, {
28179
+ mobileVisible: true
28180
+ });
28181
+ });
28182
+ onPointerDown(item.type, containerType != null ? containerType : null, item);
28183
+ }
28184
+ } else {
28185
+ var _document$elementFrom;
28186
+ // Handle as a drag end
28187
+ var simulatedEvent = new MouseEvent('mouseup', {
28188
+ clientX: touch.clientX,
28189
+ clientY: touch.clientY,
28190
+ bubbles: true
28191
+ });
28192
+ (_document$elementFrom = document.elementFromPoint(touch.clientX, touch.clientY)) == null ? void 0 : _document$elementFrom.dispatchEvent(simulatedEvent);
28193
+ }
28194
+ };
28131
28195
  var bounds = getContainerBounds();
28132
28196
  return React.createElement(Container$b, {
28133
28197
  isDraggingItem: !!draggingItem,
@@ -28139,22 +28203,12 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
28139
28203
  onPlaceDrop(data, slotIndex, containerType);
28140
28204
  }
28141
28205
  },
28142
- onTouchEnd: function onTouchEnd(e) {
28143
- var _document$elementFrom;
28144
- var _e$changedTouches$ = e.changedTouches[0],
28145
- clientX = _e$changedTouches$.clientX,
28146
- clientY = _e$changedTouches$.clientY;
28147
- var simulatedEvent = new MouseEvent('mouseup', {
28148
- clientX: clientX,
28149
- clientY: clientY,
28150
- bubbles: true
28151
- });
28152
- (_document$elementFrom = document.elementFromPoint(clientX, clientY)) == null ? void 0 : _document$elementFrom.dispatchEvent(simulatedEvent);
28153
- },
28154
28206
  onPointerDown: onDragStart !== undefined && onDragEnd !== undefined ? undefined : function () {
28155
28207
  if (item) onPointerDown(item.type, containerType != null ? containerType : null, item);
28156
28208
  },
28157
- isSelectingShortcut: isSelectingShortcut && ((item == null ? void 0 : item.type) === ItemType.Consumable || (item == null ? void 0 : item.type) === ItemType.Tool || (item == null ? void 0 : item.subType) === ItemSubType.Seed)
28209
+ isSelectingShortcut: isSelectingShortcut && ((item == null ? void 0 : item.type) === ItemType.Consumable || (item == null ? void 0 : item.type) === ItemType.Tool || (item == null ? void 0 : item.subType) === ItemSubType.Seed),
28210
+ onTouchStart: onTouchStart,
28211
+ onTouchEnd: onTouchEnd
28158
28212
  }, React.createElement(Draggable, {
28159
28213
  axis: isSelectingShortcut ? 'none' : 'both',
28160
28214
  defaultClassName: item ? 'draggable' : 'empty-slot',