From 5a967bd593a1131e3b39c0546bd8dc95b7d1e874 Mon Sep 17 00:00:00 2001 From: Aliaksei Date: Thu, 17 Aug 2023 17:09:49 +0200 Subject: [PATCH] #2838 - Bonds between atoms are not centered and not drawn symmetrically - Fix PR comment --- .../src/application/render/restruct/rebond.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/ketcher-core/src/application/render/restruct/rebond.ts b/packages/ketcher-core/src/application/render/restruct/rebond.ts index 44628dae5d..44ff344d57 100644 --- a/packages/ketcher-core/src/application/render/restruct/rebond.ts +++ b/packages/ketcher-core/src/application/render/restruct/rebond.ts @@ -525,6 +525,8 @@ function getBondPath( const shiftA = !restruct.atoms.get(hb1.begin)?.showLabel; const shiftB = !restruct.atoms.get(hb2.begin)?.showLabel; let newHalfBonds: [HalfBond, HalfBond]; + const xShiftMinus1 = -1; + const xShiftPlus1 = 1; switch (bond.b.type) { case Bond.PATTERN.TYPE.SINGLE: switch (bond.b.stereo) { @@ -637,7 +639,7 @@ function getBondPath( break; } case Bond.PATTERN.TYPE.SINGLE_OR_DOUBLE: - newHalfBonds = util.updateHalfBondCoordinates(hb1, hb2, 1); + newHalfBonds = util.updateHalfBondCoordinates(hb1, hb2, xShiftPlus1); path = getSingleOrDoublePath( render, newHalfBonds[0], @@ -657,7 +659,7 @@ function getBondPath( ); break; case Bond.PATTERN.TYPE.DOUBLE_OR_AROMATIC: - newHalfBonds = util.updateHalfBondCoordinates(hb1, hb2, -1); + newHalfBonds = util.updateHalfBondCoordinates(hb1, hb2, xShiftMinus1); path = getBondAromaticPath( render, newHalfBonds[0], @@ -669,7 +671,7 @@ function getBondPath( ); break; case Bond.PATTERN.TYPE.ANY: - newHalfBonds = util.updateHalfBondCoordinates(hb1, hb2, -1); + newHalfBonds = util.updateHalfBondCoordinates(hb1, hb2, xShiftMinus1); path = draw.bondAny( render.paper, newHalfBonds[0], @@ -679,7 +681,7 @@ function getBondPath( ); break; case Bond.PATTERN.TYPE.HYDROGEN: - newHalfBonds = util.updateHalfBondCoordinates(hb1, hb2, 1); + newHalfBonds = util.updateHalfBondCoordinates(hb1, hb2, xShiftPlus1); path = draw.bondHydrogen( render.paper, newHalfBonds[0],