Skip to content

Charges change size and centering #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
xavierholt opened this issue Mar 6, 2025 · 2 comments
Open

Charges change size and centering #195

xavierholt opened this issue Mar 6, 2025 · 2 comments

Comments

@xavierholt
Copy link
Collaborator

If the last atom in a SMILES string has a charge, the resulting molecule draws smaller and not quite centered:

Image
@xavierholt
Copy link
Collaborator Author

Actually, this is more likely about the leftmost atom in the drawing rather than the first atom in the input (which does tend to end up on the left). Line ~645 in SvgWrapper.js:

// ... but for direction left move to the right to 
if (direction === 'left' && text[0][0] !== text[0][1]) {
  bbox.width *= 2.0;
}

Atoms in the left direction get a double-width bounding box for some reason, and then this is used a little later to update the bounding box for the whole drawing, pushing things off center.

@xavierholt
Copy link
Collaborator Author

Any fix to this should probably include a fix for #207, and vice versa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant