From 97db013e45dc3828d959210386bba16e1f6c0054 Mon Sep 17 00:00:00 2001 From: Bill Date: Wed, 30 Jun 2021 19:47:48 -0400 Subject: [PATCH] Add noFollow option to ObjectLocationView --- .../object-location/ObjectLocationView.tsx | 19 +++++++++++++++---- .../ObjectLocationView.types.ts | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/views/room/widgets/object-location/ObjectLocationView.tsx b/src/views/room/widgets/object-location/ObjectLocationView.tsx index c5f2b142..04bf1f20 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, category = -1, children = null } = props; + const { objectId = -1, category = -1, noFollow = false, children = null } = props; const [ pos, setPos ] = useState<{ x: number, y: number }>({ x: -1, y: -1}); const elementRef = useRef(); @@ -31,13 +31,24 @@ export const ObjectLocationView: FC = props => useEffect(() => { - Nitro.instance.ticker.add(updatePosition); + let remove = false; + + if(noFollow) + { + updatePosition(); + } + else + { + remove = true; + + Nitro.instance.ticker.add(updatePosition); + } return () => { - Nitro.instance.ticker.remove(updatePosition); + if(remove) Nitro.instance.ticker.remove(updatePosition); } - }, [ updatePosition ]); + }, [ updatePosition, noFollow ]); return (
-1 ? 'visible' : 'invisible') } style={ { left: pos.x, top: pos.y } }> diff --git a/src/views/room/widgets/object-location/ObjectLocationView.types.ts b/src/views/room/widgets/object-location/ObjectLocationView.types.ts index 75e67971..8c29df71 100644 --- a/src/views/room/widgets/object-location/ObjectLocationView.types.ts +++ b/src/views/room/widgets/object-location/ObjectLocationView.types.ts @@ -2,4 +2,5 @@ export interface ObjectLocationViewProps { objectId: number; category: number; + noFollow?: boolean; }