Skip to content

Commit

Permalink
#2838 - Bonds between atoms are not centered and not drawn symmetrically
Browse files Browse the repository at this point in the history
- Fix PR comment
  • Loading branch information
Aliaksei committed Aug 17, 2023
1 parent 3c2a1e1 commit 5a967bd
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/ketcher-core/src/application/render/restruct/rebond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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],
Expand All @@ -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],
Expand All @@ -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],
Expand All @@ -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],
Expand Down

0 comments on commit 5a967bd

Please sign in to comment.