fix(ui): improved dropdown positioning, added rich data to corpse loot
This commit is contained in:
@@ -57,7 +57,10 @@ export const GameDropdown: React.FC<GameDropdownProps> = ({
|
||||
if (!isOpen) return null;
|
||||
|
||||
// Adjust position to keep within viewport
|
||||
let { x, y } = position;
|
||||
// Default offset of -10 to center mouse over menu
|
||||
let x = position.x - 10;
|
||||
let y = position.y - 10;
|
||||
let flipUp = false;
|
||||
|
||||
// Simple adjustment logic (can be improved with measuring ref)
|
||||
// We'll trust the parent passed reasonable coords, but ensure it doesn't go off-screen right/bottom
|
||||
@@ -75,9 +78,7 @@ export const GameDropdown: React.FC<GameDropdownProps> = ({
|
||||
|
||||
if (y + estimatedHeight > viewportHeight) {
|
||||
// Flip up if space
|
||||
y = y - estimatedHeight;
|
||||
// Or just limit to bottom
|
||||
if (y < 0) y = 10;
|
||||
flipUp = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +87,8 @@ export const GameDropdown: React.FC<GameDropdownProps> = ({
|
||||
ref={dropdownRef}
|
||||
className={`game-dropdown-menu ${className}`}
|
||||
style={{
|
||||
top: y,
|
||||
top: flipUp ? 'auto' : y,
|
||||
bottom: flipUp ? (window.innerHeight - y) : 'auto',
|
||||
left: x,
|
||||
width: width
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user