-
Notifications
You must be signed in to change notification settings - Fork 60
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
fix(web): center markers in sequence views #709
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,8 @@ function SequenceMarkerMutationDisconnected({ | |
|
||
const fill = getNucleotideColor(queryNuc) | ||
const width = Math.max(BASE_MIN_WIDTH_PX, pixelsPerBase) | ||
const x = pos * pixelsPerBase - width / 2 | ||
const halfNuc = Math.max(pixelsPerBase, BASE_MIN_WIDTH_PX) / 2 // Anchor on the center of the first nuc | ||
const x = pos * pixelsPerBase - halfNuc | ||
Comment on lines
-59
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only non-range marker changed: the nuc substitution marker. Similarly, I shift it to the left by half a nuc. Note it was already shifted before by (width / 2). But because width is always 1 nuc, I find it more explicit to subtract the half a nuc. Gives the same result, but looks more in line with the rest of markers. |
||
|
||
const totalAaChanges = aaSubstitutions.length + aaDeletions.length | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's take the missing range (N nucs) as an example.
I take a max of "pixels per nuc" and "min nuc width", which gives the width of a single nuc for this particular marker in pixels.
Then I take half of this number, which gives a half of a nuc.
I subtract this half-nuc-width from the x position of the rectangle representing the range.
Elements in SVG are anchored on their left edges by default. So subtracting half a nuc shifts the rectangle by half a nuc to the left. This way it looks as if it is anchored at the center of the first nuc in the range.