diff --git a/web/src/components/inventory/InventoryHotbar.tsx b/web/src/components/inventory/InventoryHotbar.tsx index 6725bba5ae..caad53b673 100644 --- a/web/src/components/inventory/InventoryHotbar.tsx +++ b/web/src/components/inventory/InventoryHotbar.tsx @@ -31,7 +31,7 @@ const InventoryHotbar: React.FC = () => {
diff --git a/web/src/components/inventory/InventorySlot.tsx b/web/src/components/inventory/InventorySlot.tsx index 12de155d08..c7aa461dfa 100644 --- a/web/src/components/inventory/InventorySlot.tsx +++ b/web/src/components/inventory/InventorySlot.tsx @@ -49,7 +49,7 @@ const InventorySlot: React.ForwardRefRenderFunction = name: item.name, slot: item.slot, }, - image: item?.name && `url(${getItemUrl(item) || 'none'}`, + image: item?.name ? `url(${getItemUrl(item)})` : 'none', } : null, canDrag, @@ -131,7 +131,7 @@ const InventorySlot: React.ForwardRefRenderFunction = ? 'brightness(80%) grayscale(100%)' : undefined, opacity: isDragging ? 0.4 : 1.0, - backgroundImage: `url(${item?.name ? getItemUrl(item as SlotWithItem) : 'none'}`, + backgroundImage: item?.name ? `url(${getItemUrl(item as SlotWithItem)})` : 'none', border: isOver ? '1px dashed rgba(255,255,255,0.4)' : '', }} > diff --git a/web/src/components/utils/DragPreview.tsx b/web/src/components/utils/DragPreview.tsx index 2051fa2c17..b256ffd4b4 100644 --- a/web/src/components/utils/DragPreview.tsx +++ b/web/src/components/utils/DragPreview.tsx @@ -30,12 +30,12 @@ export const calculatePointerPosition = (monitor: DragLayerMonitor, childRef: Re return null; } - if (!childRef.current || !childRef.current.getBoundingClientRect) { + if (!childRef.current) { return subtract(offset, calculateParentOffset(monitor)); } - const bb = childRef.current.getBoundingClientRect(); - const middle = { x: bb.width / 2, y: bb.height / 2 }; + const el = childRef.current as HTMLElement; + const middle = { x: el.clientWidth / 2, y: el.clientHeight / 2 }; return subtract(offset, middle); }; @@ -55,7 +55,7 @@ const DragPreview: React.FC = () => { className="item-drag-preview" ref={element} style={{ - transform: `translate(${currentOffset.x}px, ${currentOffset.y}px)`, + transform: `translate3d(${currentOffset.x}px, ${currentOffset.y}px, 0)`, backgroundImage: data.image, }} /> diff --git a/web/src/components/utils/ItemNotifications.tsx b/web/src/components/utils/ItemNotifications.tsx index 5a6eb6eb58..a8c5e7d65c 100644 --- a/web/src/components/utils/ItemNotifications.tsx +++ b/web/src/components/utils/ItemNotifications.tsx @@ -32,7 +32,7 @@ const ItemNotification = React.forwardRef(
{ duration: 200, }); - const handleMouseMove = ({ clientX, clientY }: MouseEvent | React.MouseEvent) => { - refs.setPositionReference({ - getBoundingClientRect() { - return { - width: 0, - height: 0, - x: clientX, - y: clientY, - left: clientX, - top: clientY, - right: clientX, - bottom: clientY, - }; - }, - }); - }; - useEffect(() => { + if (!hoverData.open) return; + + const handleMouseMove = ({ clientX, clientY }: MouseEvent) => { + refs.setPositionReference({ + getBoundingClientRect() { + return { + width: 0, + height: 0, + x: clientX, + y: clientY, + left: clientX, + top: clientY, + right: clientX, + bottom: clientY, + }; + }, + }); + }; + window.addEventListener('mousemove', handleMouseMove); return () => { window.removeEventListener('mousemove', handleMouseMove); }; - }, []); + }, [hoverData.open, refs]); return ( <>