@@ -142,20 +142,27 @@ export const ProcessEventDot = styled(
142142 const activeDescendantId = useSelector ( selectors . uiActiveDescendantId ) ;
143143 const selectedDescendantId = useSelector ( selectors . uiSelectedDescendantId ) ;
144144
145+ const logicalProcessNodeViewWidth = 360 ;
146+ const logicalProcessNodeViewHeight = 120 ;
147+ /**
148+ * The `left` and `top` values represent the 'center' point of the process node.
149+ * Since the view has content to the left and above the 'center' point, offset the
150+ * position to accomodate for that. This aligns the logical center of the process node
151+ * with the correct position on the map.
152+ */
153+ const processNodeViewXOffset = - 0.172413 * logicalProcessNodeViewWidth * magFactorX ;
154+ const processNodeViewYOffset = - 0.73684 * logicalProcessNodeViewHeight * magFactorX ;
155+
145156 const nodeViewportStyle = useMemo (
146157 ( ) => ( {
147- left : `${ left } px` ,
148- top : `${ top } px` ,
158+ left : `${ left + processNodeViewXOffset } px` ,
159+ top : `${ top + processNodeViewYOffset } px` ,
149160 // Width of symbol viewport scaled to fit
150- width : `${ 360 * magFactorX } px` ,
161+ width : `${ logicalProcessNodeViewWidth * magFactorX } px` ,
151162 // Height according to symbol viewbox AR
152- height : `${ 120 * magFactorX } px` ,
153- // Adjusted to position/scale with camera
154- transform : `translateX(-${ 0.172413 * 360 * magFactorX + 10 } px) translateY(-${ 0.73684 *
155- 120 *
156- magFactorX } px)`,
163+ height : `${ logicalProcessNodeViewHeight * magFactorX } px` ,
157164 } ) ,
158- [ left , magFactorX , top ]
165+ [ left , magFactorX , processNodeViewXOffset , processNodeViewYOffset , top ]
159166 ) ;
160167
161168 /**
@@ -202,32 +209,26 @@ export const ProcessEventDot = styled(
202209
203210 const dispatch = useResolverDispatch ( ) ;
204211
205- const handleFocus = useCallback (
206- ( focusEvent : React . FocusEvent < HTMLDivElement > ) => {
207- dispatch ( {
208- type : 'userFocusedOnResolverNode' ,
209- payload : {
210- nodeId,
211- } ,
212- } ) ;
213- } ,
214- [ dispatch , nodeId ]
215- ) ;
212+ const handleFocus = useCallback ( ( ) => {
213+ dispatch ( {
214+ type : 'userFocusedOnResolverNode' ,
215+ payload : {
216+ nodeId,
217+ } ,
218+ } ) ;
219+ } , [ dispatch , nodeId ] ) ;
216220
217- const handleClick = useCallback (
218- ( clickEvent : React . MouseEvent < HTMLDivElement , MouseEvent > ) => {
219- if ( animationTarget . current !== null ) {
220- ( animationTarget . current as any ) . beginElement ( ) ;
221- }
222- dispatch ( {
223- type : 'userSelectedResolverNode' ,
224- payload : {
225- nodeId,
226- } ,
227- } ) ;
228- } ,
229- [ animationTarget , dispatch , nodeId ]
230- ) ;
221+ const handleClick = useCallback ( ( ) => {
222+ if ( animationTarget . current !== null ) {
223+ ( animationTarget . current as any ) . beginElement ( ) ;
224+ }
225+ dispatch ( {
226+ type : 'userSelectedResolverNode' ,
227+ payload : {
228+ nodeId,
229+ } ,
230+ } ) ;
231+ } , [ animationTarget , dispatch , nodeId ] ) ;
231232
232233 /* eslint-disable jsx-a11y/click-events-have-key-events */
233234 /**
@@ -373,13 +374,11 @@ export const ProcessEventDot = styled(
373374 )
374375) `
375376 position: absolute;
376- display: block;
377377 text-align: left;
378378 font-size: 10px;
379379 user-select: none;
380380 box-sizing: border-box;
381381 border-radius: 10%;
382- padding: 4px;
383382 white-space: nowrap;
384383 will-change: left, top, width, height;
385384 contain: strict;
0 commit comments