@rpg-engine/long-bow 0.5.30 → 0.5.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.5.30",
3
+ "version": "0.5.32",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -117,7 +117,7 @@ export const ItemSlot: React.FC<IProps> = observer(
117
117
  const [dropPosition, setDropPosition] = useState<IPosition | null>(null);
118
118
  const dragContainer = useRef<HTMLDivElement>(null);
119
119
 
120
- const { setDraggingItem } = useDragging();
120
+ const { item: draggingItem, setDraggingItem } = useDragging();
121
121
 
122
122
  const [contextActions, setContextActions] = useState<IContextMenuItem[]>(
123
123
  []
@@ -160,6 +160,7 @@ export const ItemSlot: React.FC<IProps> = observer(
160
160
  setDraggingItem(null);
161
161
 
162
162
  const target = e.target as HTMLElement;
163
+
163
164
  if (target?.id.includes('shortcutSetter') && setItemShortcut && item) {
164
165
  const index = parseInt(target.id.split('_')[1]);
165
166
  if (!isNaN(index)) {
@@ -167,6 +168,11 @@ export const ItemSlot: React.FC<IProps> = observer(
167
168
  }
168
169
  }
169
170
 
171
+ // remove the class react-draggable-dragging from the element
172
+ // to prevent the item from being dragged again
173
+
174
+ target.classList.remove('react-draggable-dragging');
175
+
170
176
  if (wasDragged && item && !isSelectingShortcut) {
171
177
  //@ts-ignore
172
178
  const classes: string[] = Array.from(e.target?.classList);
@@ -241,8 +247,6 @@ export const ItemSlot: React.FC<IProps> = observer(
241
247
  }
242
248
 
243
249
  if (onDragStart && containerType) {
244
- setDraggingItem(item);
245
-
246
250
  onDragStart(item, slotIndex, containerType);
247
251
  }
248
252
  };
@@ -255,10 +259,15 @@ export const ItemSlot: React.FC<IProps> = observer(
255
259
  setWasDragged(true);
256
260
  setIsFocused(true);
257
261
  }
262
+
263
+ if (!draggingItem) {
264
+ setDraggingItem(item);
265
+ }
258
266
  };
259
267
 
260
268
  return (
261
269
  <Container
270
+ isDraggingItem={!!draggingItem}
262
271
  item={item}
263
272
  className="rpgui-icon empty-slot"
264
273
  onMouseUp={() => {
@@ -363,13 +372,15 @@ interface ContainerTypes {
363
372
  item: IItem | null;
364
373
  containerType?: ItemContainerType | null;
365
374
  isSelectingShortcut?: boolean;
375
+ isDraggingItem?: boolean;
366
376
  }
367
377
 
368
378
  const Container = styled.div<ContainerTypes>`
369
379
  margin: 0.1rem;
370
380
 
371
381
  .react-draggable-dragging {
372
- opacity: 0;
382
+ // if is dragging item, set opacity to 0
383
+ opacity: ${({ isDraggingItem }) => (isDraggingItem ? 0 : 1)};
373
384
  }
374
385
 
375
386
  position: relative;