Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private computeOffsets(
commits: Element[],
): GitgraphState["commitYWithOffsets"] {
let totalOffsetY = 0;
// In VerticalReverse orientation, commits are in the same order in the DOM.
const orientedCommits =
this.gitgraph.orientation === Orientation.VerticalReverse
? commits
: commits.reverse();
return orientedCommits.reduce(
(newOffsets, commit) => {
const commitY = parseInt(
commit
.getAttribute("transform")!
.split(",")[1]
.slice(0, -1),
10,
);
const firstForeignObject = commit.getElementsByTagName(
"foreignObject",
)[0];
function computeOffsets(): void {
const commits: Element[] = Array.from($commits.children);
let totalOffsetY = 0;
// In VerticalReverse orientation, commits are in the same order in the DOM.
const orientedCommits =
gitgraph.orientation === Orientation.VerticalReverse
? commits
: commits.reverse();
commitYWithOffsets = orientedCommits.reduce(
(newOffsets, commit) => {
const commitY = parseInt(
commit
.getAttribute("transform")!
.split(",")[1]
.slice(0, -1),
10,
);
const firstForeignObject = commit.getElementsByTagName(
"foreignObject",
)[0];