Skip to content

Commit

Permalink
fix: don't shift svg rectangles by half-width
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-aksamentov committed Jun 18, 2020
1 parent d3a90d9 commit 481359b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/web/src/components/Main/GeneMap.tsx
Expand Up @@ -20,10 +20,10 @@ export function getGeneId(gene: GeneMapDatum) {

export function GeneView({ gene, pixelsPerBase, ...rest }: GeneViewProps) {
const { end, start } = gene
const widthPx = Math.max(BASE_MIN_WIDTH_PX, (end - start) * pixelsPerBase)
const x = start * pixelsPerBase + widthPx / 2
const width = Math.max(BASE_MIN_WIDTH_PX, (end - start) * pixelsPerBase)
const x = start * pixelsPerBase
const id = getGeneId(gene)
return <rect id={id} fill={gene.color} x={x} y={-10} width={widthPx} height="30" {...rest} />
return <rect id={id} fill={gene.color} x={x} y={-10} width={width} height="30" {...rest} />
}

export function GeneMap() {
Expand Down
8 changes: 4 additions & 4 deletions packages/web/src/components/Main/InvalidView.tsx
Expand Up @@ -13,8 +13,8 @@ export interface InvalidViewProps extends SVGProps<SVGRectElement> {
export function InvalidView({ inv, pixelsPerBase, ...rest }: InvalidViewProps) {
const { id, character, begin, end } = inv
const fill = getBaseColor(character)
let widthPx = (end - begin) * pixelsPerBase
const x = begin * pixelsPerBase + widthPx * 0.5
widthPx = Math.max(BASE_MIN_WIDTH_PX)
return <rect id={id} fill={fill} x={x} y={-10} width={widthPx} height="30" {...rest} />
let width = (end - begin) * pixelsPerBase
const x = begin * pixelsPerBase
width = Math.max(BASE_MIN_WIDTH_PX)
return <rect id={id} fill={fill} x={x} y={-10} width={width} height="30" {...rest} />
}

0 comments on commit 481359b

Please sign in to comment.