minecraft-inventory 0.1.31 → 0.1.33
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
|
@@ -229,16 +229,13 @@ export function Slot({
|
|
|
229
229
|
const handleWheel = useCallback(
|
|
230
230
|
(e: WheelEvent) => {
|
|
231
231
|
if (isMobile || disabled) return
|
|
232
|
+
if (onClickOverride) return // JEI slots: let parent handle wheel for pagination
|
|
232
233
|
if (!item && !heldItem) return
|
|
233
234
|
e.preventDefault()
|
|
234
|
-
if (
|
|
235
|
-
|
|
236
|
-
} else {
|
|
237
|
-
|
|
238
|
-
sendAction({ type: 'click', slotIndex: index, button: 'right', mode: 'normal' })
|
|
239
|
-
} else if (e.deltaY > 0 && heldItem) {
|
|
240
|
-
sendAction({ type: 'click', slotIndex: index, button: 'right', mode: 'normal' })
|
|
241
|
-
}
|
|
235
|
+
if (e.deltaY < 0 && item) {
|
|
236
|
+
sendAction({ type: 'click', slotIndex: index, button: 'right', mode: 'normal' })
|
|
237
|
+
} else if (e.deltaY > 0 && heldItem) {
|
|
238
|
+
sendAction({ type: 'click', slotIndex: index, button: 'right', mode: 'normal' })
|
|
242
239
|
}
|
|
243
240
|
},
|
|
244
241
|
[isMobile, disabled, item, heldItem, sendAction, index, onClickOverride],
|
|
@@ -360,6 +360,27 @@ export function InventoryProvider({ connector, children, noDragSpread = false, n
|
|
|
360
360
|
setDragRemainder(null)
|
|
361
361
|
}, [])
|
|
362
362
|
|
|
363
|
+
// Global mouseup listener to finalize drag when the button is released outside slot elements.
|
|
364
|
+
// Slot.handleMouseUp calls e.stopPropagation(), so when mouseup lands on a slot the window
|
|
365
|
+
// listener does NOT fire — the two handlers are mutually exclusive.
|
|
366
|
+
useEffect(() => {
|
|
367
|
+
if (!isDragging) return
|
|
368
|
+
|
|
369
|
+
const handleGlobalMouseUp = () => {
|
|
370
|
+
endDrag()
|
|
371
|
+
}
|
|
372
|
+
const handleBlur = () => {
|
|
373
|
+
cancelDrag()
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
window.addEventListener('mouseup', handleGlobalMouseUp)
|
|
377
|
+
window.addEventListener('blur', handleBlur)
|
|
378
|
+
return () => {
|
|
379
|
+
window.removeEventListener('mouseup', handleGlobalMouseUp)
|
|
380
|
+
window.removeEventListener('blur', handleBlur)
|
|
381
|
+
}
|
|
382
|
+
}, [isDragging, endDrag, cancelDrag])
|
|
383
|
+
|
|
363
384
|
const getSlot = useCallback(
|
|
364
385
|
(index: number) => {
|
|
365
386
|
return windowState?.slots.find((s) => s.index === index)
|