@@ -354,7 +354,9 @@ export const _linePath = (
354354 const [ xm , ym ] = path [ 'end' ] ;
355355
356356 // turnX: vertical turn position, offset from bifurcation point towards branch
357- const branchDirection = xBranch > xBifurcate ? 1 : - 1 ;
357+ // Offset moves turnX in the opposite direction of train travel (towards branch)
358+ const branchOnRight = xBranch > xBifurcate ;
359+ const branchDirection = branchOnRight ? 1 : - 1 ;
358360 const turnX = xBifurcate + branchDirection * branchOffset ;
359361
360362 if ( type === 'main' ) {
@@ -369,7 +371,7 @@ export const _linePath = (
369371 } else {
370372 // main line, left direction, upper to center (merging back to main line)
371373 if ( bend === 'rightangle' ) {
372- return `M ${ x } ,${ y } V ${ ym } H ${ turnX } H ${ xm } ` ;
374+ return `M ${ x } ,${ y } H ${ turnX } V ${ ym } H ${ xm } ` ;
373375 }
374376 // upper to center/rightangle, center to lower/diagonal
375377 else return `M ${ x - e1 } ,${ y } H ${ xBranch + e2 } L ${ xm - e2 } ,${ ym } H ${ xm } ` ;
@@ -404,7 +406,7 @@ export const _linePath = (
404406 } else {
405407 // pass line, left direction, upper to center (merging)
406408 if ( bend === 'rightangle' ) {
407- return `M ${ x } ,${ y } V ${ ym } H ${ turnX } H ${ xm + e1 } ` ;
409+ return `M ${ x } ,${ y } H ${ turnX } V ${ ym } H ${ xm + e1 } ` ;
408410 }
409411 // upper to center/rightangle, center to lower/diagonal
410412 else return `M ${ x - e1 } ,${ y } H ${ xBranch + e2 } L ${ xm - e2 } ,${ ym } H ${ xm } ` ;
0 commit comments