castle-web-cli 0.4.89 → 0.4.90

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.
@@ -25,11 +25,28 @@ export function BlueprintLibrary({
25
25
  }) {
26
26
  const blueprints = listBlueprints(files);
27
27
  const dragRef = useRef(null);
28
+ const hotbarRef = useRef(null);
28
29
  const suppressClickRef = useRef(false);
29
30
  const [dragPreview, setDragPreview] = useState(null);
30
31
  const [contextMenu, setContextMenu] = useState(null);
31
32
  const [confirmDelete, setConfirmDelete] = useState(null);
32
33
 
34
+ // Map a vertical mouse wheel gesture onto horizontal scroll so plain-mouse
35
+ // users (no trackpad/touch) can pan the hotbar. Bound natively rather than via
36
+ // React's onWheel so the listener is non-passive and can preventDefault.
37
+ useEffect(() => {
38
+ const bar = hotbarRef.current;
39
+ if (!bar) return undefined;
40
+ const onWheel = (event) => {
41
+ if (event.deltaY !== 0 && Math.abs(event.deltaY) > Math.abs(event.deltaX)) {
42
+ bar.scrollLeft += event.deltaY;
43
+ event.preventDefault();
44
+ }
45
+ };
46
+ bar.addEventListener('wheel', onWheel, { passive: false });
47
+ return () => bar.removeEventListener('wheel', onWheel);
48
+ }, []);
49
+
33
50
  const onSlotContextMenu = (event, blueprint) => {
34
51
  if (isPlaying) return;
35
52
  event.preventDefault();
@@ -99,7 +116,7 @@ export function BlueprintLibrary({
99
116
  };
100
117
 
101
118
  return (
102
- <div className={styles.bpHotbar} aria-label="Blueprints">
119
+ <div ref={hotbarRef} className={styles.bpHotbar} aria-label="Blueprints">
103
120
  <button
104
121
  type="button"
105
122
  className={styles.bpActionSlot}
@@ -25,11 +25,28 @@ export function BlueprintLibrary({
25
25
  }) {
26
26
  const blueprints = listBlueprints(files);
27
27
  const dragRef = useRef(null);
28
+ const hotbarRef = useRef(null);
28
29
  const suppressClickRef = useRef(false);
29
30
  const [dragPreview, setDragPreview] = useState(null);
30
31
  const [contextMenu, setContextMenu] = useState(null);
31
32
  const [confirmDelete, setConfirmDelete] = useState(null);
32
33
 
34
+ // Map a vertical mouse wheel gesture onto horizontal scroll so plain-mouse
35
+ // users (no trackpad/touch) can pan the hotbar. Bound natively rather than via
36
+ // React's onWheel so the listener is non-passive and can preventDefault.
37
+ useEffect(() => {
38
+ const bar = hotbarRef.current;
39
+ if (!bar) return undefined;
40
+ const onWheel = (event) => {
41
+ if (event.deltaY !== 0 && Math.abs(event.deltaY) > Math.abs(event.deltaX)) {
42
+ bar.scrollLeft += event.deltaY;
43
+ event.preventDefault();
44
+ }
45
+ };
46
+ bar.addEventListener('wheel', onWheel, { passive: false });
47
+ return () => bar.removeEventListener('wheel', onWheel);
48
+ }, []);
49
+
33
50
  const onSlotContextMenu = (event, blueprint) => {
34
51
  if (isPlaying) return;
35
52
  event.preventDefault();
@@ -99,7 +116,7 @@ export function BlueprintLibrary({
99
116
  };
100
117
 
101
118
  return (
102
- <div className={styles.bpHotbar} aria-label="Blueprints">
119
+ <div ref={hotbarRef} className={styles.bpHotbar} aria-label="Blueprints">
103
120
  <button
104
121
  type="button"
105
122
  className={styles.bpActionSlot}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "castle-web-cli",
3
- "version": "0.4.89",
3
+ "version": "0.4.90",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "castle-web": "./dist/index.js"