Skip to content
This repository was archived by the owner on Jul 13, 2024. It is now read-only.

Commit bed23ff

Browse files
author
Nicolas Carlo
committed
Set tag data-offset on container
1 parent bec76a7 commit bed23ff

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/gitgraph-js/src/gitgraph.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ function createGitgraph(
211211
moveElement(tag, x);
212212

213213
// BBox width misses box padding and offset
214-
// => they are set later, on branch label update.
215-
// We would need to make branch label update happen before to solve it.
214+
// => they are set later, on tag update.
215+
// We would need to make tag update happen before to solve it.
216216
const offset = parseFloat(tag.getAttribute("data-offset") || "0");
217217
const tagWidth = tag.getBBox().width + 2 * TAG_PADDING_X + offset;
218218
x += tagWidth + padding;
@@ -469,6 +469,12 @@ function createGitgraph(
469469
translate: { x: 0, y: commit.style.dot.size },
470470
children: [tagElement],
471471
});
472+
// `data-offset` is used to position tag element in `positionCommitsElements`.
473+
// => because when it's executed, tag offsets are not resolved yet
474+
tagContainer.setAttribute(
475+
"data-offset",
476+
tag.style.pointerWidth.toString(),
477+
);
472478

473479
setTagRef(commit, tagContainer);
474480

packages/gitgraph-js/src/tag.ts

-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ function createTag(tag: Tag<SVGElement>): SVGGElement {
2020
});
2121

2222
const result = createG({ children: [path] });
23-
// Pass computed box width to gitgraph so it can adapt.
2423
const offset = tag.style.pointerWidth;
25-
result.setAttribute("data-offset", offset.toString());
2624

2725
const observer = new MutationObserver(() => {
2826
const { height, width } = text.getBBox();

0 commit comments

Comments
 (0)