fix: card image vertical alignment
This commit is contained in:
@@ -129,6 +129,8 @@ function GraphThumbnail({ projectId, className }: { projectId: string; className
|
||||
}
|
||||
|
||||
const padding = 12
|
||||
const viewBoxW = 200
|
||||
const viewBoxH = 120
|
||||
const xs = withPos.map((n) => n.position!.x)
|
||||
const ys = withPos.map((n) => n.position!.y)
|
||||
const minX = Math.min(...xs)
|
||||
@@ -137,9 +139,11 @@ function GraphThumbnail({ projectId, className }: { projectId: string; className
|
||||
const maxY = Math.max(...ys)
|
||||
const w = Math.max(maxX - minX, 1)
|
||||
const h = Math.max(maxY - minY, 1)
|
||||
const scale = Math.min((200 - padding * 2) / w, (120 - padding * 2) / h, 8)
|
||||
const ox = padding - minX * scale
|
||||
const oy = padding - minY * scale
|
||||
const scale = Math.min((viewBoxW - padding * 2) / w, (viewBoxH - padding * 2) / h, 8)
|
||||
const graphW = w * scale
|
||||
const graphH = h * scale
|
||||
const ox = (viewBoxW - graphW) / 2 - minX * scale
|
||||
const oy = (viewBoxH - graphH) / 2 - minY * scale
|
||||
|
||||
const nodeById = new Map(withPos.map((n) => [n.id, n]))
|
||||
const validEdges = edges.filter((e) => nodeById.has(e.source) && nodeById.has(e.target))
|
||||
|
||||
Reference in New Issue
Block a user