@rpg-engine/long-bow 0.7.50 → 0.7.51

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,9 +27930,6 @@ 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
- dragStartTime = _useState5[0],
27935
- setDragStartTime = _useState5[1];
27936
27933
  useEffect(function () {
27937
27934
  setDragState(function (prev) {
27938
27935
  return _extends({}, prev, {
@@ -28014,8 +28011,10 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
28014
28011
  // remove the class react-draggable-dragging from the element
28015
28012
  // to prevent the item from being dragged again
28016
28013
  target.classList.remove('react-draggable-dragging');
28017
- var dragEndTime = Date.now();
28018
- var dragDuration = dragStartTime ? dragEndTime - dragStartTime : 0;
28014
+ var isTouch = e.type.startsWith('touch');
28015
+ // Threshold for considering a tap/click as a drag
28016
+ var dragThreshold = 5; // pixels
28017
+ var isDrag = Math.abs(data.x) > dragThreshold || Math.abs(data.y) > dragThreshold;
28019
28018
  if (dragState.wasDragged && item && !isSelectingShortcut) {
28020
28019
  var _e$target;
28021
28020
  //@ts-ignore
@@ -28071,18 +28070,14 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
28071
28070
  });
28072
28071
  }
28073
28072
  }, 50);
28074
- } else if (item && dragDuration < 200) {
28075
- // Consider it a click if drag duration is less than 200ms
28076
- var isTouch = false;
28077
- if (!isContextMenuDisabled && e.type === 'touchend' && !isSelectingShortcut) {
28078
- isTouch = true;
28073
+ } else if (item) {
28074
+ if (isTouch && !isDrag) {
28079
28075
  setTooltipState(function (prev) {
28080
28076
  return _extends({}, prev, {
28081
28077
  mobileVisible: true
28082
28078
  });
28083
28079
  });
28084
- }
28085
- if (!isContextMenuDisabled && !isSelectingShortcut && !isTouch && !dragState.wasDragged) {
28080
+ } else if (!isTouch && !isContextMenuDisabled && !isSelectingShortcut) {
28086
28081
  setContextMenuState(function (prev) {
28087
28082
  return _extends({}, prev, {
28088
28083
  visible: !contextMenuState.visible
@@ -28100,14 +28095,22 @@ var ItemSlot = /*#__PURE__*/React.memo( /*#__PURE__*/observer(function (_ref) {
28100
28095
  });
28101
28096
  }
28102
28097
  }
28103
- onPointerDown(item.type, containerType != null ? containerType : null, item);
28098
+ if (!isDrag || !isTouch) {
28099
+ console.log('Calling onPointerDown');
28100
+ onPointerDown(item.type, containerType != null ? containerType : null, item);
28101
+ }
28104
28102
  }
28103
+ setDragState(function (prev) {
28104
+ return _extends({}, prev, {
28105
+ wasDragged: false
28106
+ });
28107
+ });
28108
+ console.log('Final dragState:', dragState);
28105
28109
  };
28106
28110
  var onDraggableStart = function onDraggableStart() {
28107
28111
  if (!item || isSelectingShortcut) {
28108
28112
  return;
28109
28113
  }
28110
- setDragStartTime(Date.now());
28111
28114
  if (onDragStart && containerType) {
28112
28115
  onDragStart(item, slotIndex, containerType);
28113
28116
  }