diff --git a/src/views/room/widgets/object-location/ObjectLocationView.tsx b/src/views/room/widgets/object-location/ObjectLocationView.tsx index d8547608..e13baa94 100644 --- a/src/views/room/widgets/object-location/ObjectLocationView.tsx +++ b/src/views/room/widgets/object-location/ObjectLocationView.tsx @@ -5,7 +5,7 @@ import { ObjectLocationViewProps } from './ObjectLocationView.types'; export const ObjectLocationView: FC = props => { - const { objectId = -1, objectType = -1, children = null } = props; + const { objectId = -1, category = -1, children = null } = props; const [ posX, setPosX ] = useState(0); const [ posY, setPosY ] = useState(0); const elementRef = useRef(); @@ -13,13 +13,13 @@ export const ObjectLocationView: FC = props => const updatePosition = useCallback(() => { const roomSession = GetRoomSession(); - const objectBounds = GetRoomEngine().getRoomObjectBoundingRectangle(roomSession.roomId, objectId, objectType, 1); + const objectBounds = GetRoomEngine().getRoomObjectBoundingRectangle(roomSession.roomId, objectId, category, 1); - if(!objectBounds) return; + if(!objectBounds || !elementRef.current) return; setPosX(Math.round(((objectBounds.left + (objectBounds.width / 2)) - (elementRef.current.offsetWidth / 2)))); setPosY(Math.round((objectBounds.top - elementRef.current.offsetHeight) + 10)); - }, [ objectId, objectType ]); + }, [ objectId, category ]); useEffect(() => { @@ -32,7 +32,7 @@ export const ObjectLocationView: FC = props => }, [ updatePosition ]); return ( -
+
{ children }
); diff --git a/src/views/room/widgets/object-location/ObjectLocationView.types.ts b/src/views/room/widgets/object-location/ObjectLocationView.types.ts index 807c76a9..75e67971 100644 --- a/src/views/room/widgets/object-location/ObjectLocationView.types.ts +++ b/src/views/room/widgets/object-location/ObjectLocationView.types.ts @@ -1,5 +1,5 @@ export interface ObjectLocationViewProps { objectId: number; - objectType: number; + category: number; }