@rpg-engine/long-bow 0.5.35 → 0.5.37

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.
@@ -15666,6 +15666,54 @@ var SlotsContainer = function SlotsContainer(_ref) {
15666
15666
  }, children);
15667
15667
  };
15668
15668
 
15669
+ var useScrollOnDrag = function useScrollOnDrag(_ref) {
15670
+ var containerRef = _ref.containerRef,
15671
+ threshold = _ref.threshold,
15672
+ scrollStep = _ref.scrollStep;
15673
+ var animationFrameId = useRef(null);
15674
+ var startScrolling = useCallback(function (clientY) {
15675
+ var scroll = function scroll() {
15676
+ if (containerRef.current) {
15677
+ var _containerRef$current = containerRef.current.getBoundingClientRect(),
15678
+ top = _containerRef$current.top,
15679
+ bottom = _containerRef$current.bottom;
15680
+ var maxScrollTop = containerRef.current.scrollHeight - containerRef.current.clientHeight;
15681
+ var distanceFromTop = clientY - top;
15682
+ var distanceFromBottom = bottom - clientY;
15683
+ if (distanceFromTop < threshold && containerRef.current.scrollTop > 0) {
15684
+ containerRef.current.scrollTop -= scrollStep;
15685
+ animationFrameId.current = requestAnimationFrame(scroll);
15686
+ } else if (distanceFromBottom < threshold && containerRef.current.scrollTop < maxScrollTop) {
15687
+ containerRef.current.scrollTop += scrollStep;
15688
+ animationFrameId.current = requestAnimationFrame(scroll);
15689
+ } else {
15690
+ // Stop scrolling if neither condition is met
15691
+ stopScrolling();
15692
+ }
15693
+ }
15694
+ };
15695
+ var stopScrolling = function stopScrolling() {
15696
+ if (animationFrameId.current !== null) {
15697
+ cancelAnimationFrame(animationFrameId.current);
15698
+ animationFrameId.current = null;
15699
+ }
15700
+ };
15701
+ //@ts-ignore
15702
+ cancelAnimationFrame(animationFrameId.current); // Cancel any existing animation frame
15703
+ animationFrameId.current = requestAnimationFrame(scroll);
15704
+ }, [containerRef, threshold, scrollStep]);
15705
+ var stopScrolling = useCallback(function () {
15706
+ if (animationFrameId.current !== null) {
15707
+ cancelAnimationFrame(animationFrameId.current);
15708
+ animationFrameId.current = null;
15709
+ }
15710
+ }, []);
15711
+ return {
15712
+ startScrolling: startScrolling,
15713
+ stopScrolling: stopScrolling
15714
+ };
15715
+ };
15716
+
15669
15717
  var ShortcutsSetter = function ShortcutsSetter(_ref) {
15670
15718
  var setSettingShortcutIndex = _ref.setSettingShortcutIndex,
15671
15719
  settingShortcutIndex = _ref.settingShortcutIndex,
@@ -15968,11 +16016,47 @@ var ItemContainer$1 = function ItemContainer(_ref) {
15968
16016
  var _useState2 = useState(-1),
15969
16017
  settingShortcutIndex = _useState2[0],
15970
16018
  setSettingShortcutIndex = _useState2[1];
16019
+ var containerRef = useRef(null);
16020
+ var _useScrollOnDrag = useScrollOnDrag({
16021
+ containerRef: containerRef,
16022
+ threshold: 50,
16023
+ scrollStep: 4
16024
+ }),
16025
+ startScrolling = _useScrollOnDrag.startScrolling,
16026
+ stopScrolling = _useScrollOnDrag.stopScrolling;
15971
16027
  var handleSetShortcut = function handleSetShortcut(item, index) {
15972
16028
  if (item.type === ItemType.Consumable || item.type === ItemType.Tool) {
15973
16029
  setItemShortcut == null ? void 0 : setItemShortcut(item.key, index);
15974
16030
  }
15975
16031
  };
16032
+ var handleMouseMove = useCallback(function (e) {
16033
+ startScrolling(e.clientY);
16034
+ }, [startScrolling]);
16035
+ var onDragStartScrollingEvents = useCallback(function () {
16036
+ document.addEventListener('pointermove', handleMouseMove);
16037
+ document.addEventListener('pointerup', function () {
16038
+ stopScrolling();
16039
+ document.removeEventListener('pointermove', handleMouseMove);
16040
+ });
16041
+ }, [handleMouseMove, onItemDragStart, stopScrolling]);
16042
+ var onDragEndScrollingEvents = useCallback(function () {
16043
+ stopScrolling();
16044
+ document.removeEventListener('pointermove', handleMouseMove);
16045
+ }, [handleMouseMove, onItemDragStart, stopScrolling]);
16046
+ var onDragStart = function onDragStart(item, slotIndex, itemContainerType) {
16047
+ console.log('DRAG START');
16048
+ if (onItemDragStart) {
16049
+ onItemDragStart(item, slotIndex, itemContainerType);
16050
+ }
16051
+ onDragStartScrollingEvents();
16052
+ };
16053
+ var onDragEnd = function onDragEnd(quantity) {
16054
+ console.log('DRAG END');
16055
+ if (onItemDragEnd) {
16056
+ onItemDragEnd(quantity);
16057
+ }
16058
+ onDragEndScrollingEvents();
16059
+ };
15976
16060
  var onRenderSlots = function onRenderSlots() {
15977
16061
  var slots = [];
15978
16062
  for (var i = 0; i < itemContainer.slotQty; i++) {
@@ -15995,12 +16079,8 @@ var ItemContainer$1 = function ItemContainer(_ref) {
15995
16079
  onSelected: function onSelected(optionId, item) {
15996
16080
  if (_onSelected) _onSelected(optionId, item);
15997
16081
  },
15998
- onDragStart: function onDragStart(item, slotIndex, itemContainerType) {
15999
- if (onItemDragStart) onItemDragStart(item, slotIndex, itemContainerType);
16000
- },
16001
- onDragEnd: function onDragEnd(quantity) {
16002
- if (onItemDragEnd) onItemDragEnd(quantity);
16003
- },
16082
+ onDragStart: onDragStart,
16083
+ onDragEnd: onDragEnd,
16004
16084
  dragScale: scale,
16005
16085
  checkIfItemCanBeMoved: checkIfItemCanBeMoved,
16006
16086
  checkIfItemShouldDragEnd: checkIfItemShouldDragEnd,
@@ -16012,10 +16092,18 @@ var ItemContainer$1 = function ItemContainer(_ref) {
16012
16092
  });
16013
16093
  },
16014
16094
  onPlaceDrop: function onPlaceDrop(item, slotIndex, itemContainerType) {
16015
- if (onItemPlaceDrop) onItemPlaceDrop(item, slotIndex, itemContainerType);
16095
+ if (onItemPlaceDrop) {
16096
+ onItemPlaceDrop(item, slotIndex, itemContainerType);
16097
+ }
16098
+ console.log('PLACE DROP');
16099
+ onDragEndScrollingEvents();
16016
16100
  },
16017
16101
  onOutsideDrop: function onOutsideDrop(item, position) {
16018
- if (_onOutsideDrop) _onOutsideDrop(item, position);
16102
+ if (_onOutsideDrop) {
16103
+ _onOutsideDrop(item, position);
16104
+ }
16105
+ console.log('OUTSIDE DROP');
16106
+ onDragEndScrollingEvents();
16019
16107
  },
16020
16108
  atlasIMG: atlasIMG,
16021
16109
  atlasJSON: atlasJSON,
@@ -16046,7 +16134,8 @@ var ItemContainer$1 = function ItemContainer(_ref) {
16046
16134
  atlasIMG: atlasIMG,
16047
16135
  atlasJSON: atlasJSON
16048
16136
  }), React.createElement(ItemsContainer, {
16049
- className: "item-container-body"
16137
+ className: "item-container-body",
16138
+ ref: containerRef
16050
16139
  }, onRenderSlots())), quantitySelect.isOpen && React.createElement(ItemQuantitySelectorModal, {
16051
16140
  quantitySelect: quantitySelect,
16052
16141
  setQuantitySelect: setQuantitySelect
@@ -17448,7 +17537,7 @@ var RPGUIScrollbar = function RPGUIScrollbar(_ref) {
17448
17537
  var Container$o = /*#__PURE__*/styled.div.withConfig({
17449
17538
  displayName: "RPGUIScrollbar__Container",
17450
17539
  componentId: "sc-p3msmb-0"
17451
- })([".rpgui-content ::-webkit-scrollbar,.rpgui-content::-webkit-scrollbar{width:25px;}.rpgui-content ::-webkit-scrollbar-track,.rpgui-content::-webkit-scrollbar-track{background-size:25px 60px;}"]);
17540
+ })([".rpgui-content ::-webkit-scrollbar,.rpgui-content::-webkit-scrollbar{width:25px !important;}.rpgui-content ::-webkit-scrollbar-track,.rpgui-content::-webkit-scrollbar-track{background-size:25px 60px !important;}"]);
17452
17541
 
17453
17542
  var RPGUIOverrides = function RPGUIOverrides(_ref) {
17454
17543
  var children = _ref.children;