Skip to content

Commit

Permalink
#5497 – Refactor (Connection.ts): Rename xOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriiP-EPAM committed Sep 11, 2024
1 parent dfdea0a commit 33540e3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export class SnakeModePolymerBondRenderer extends BaseRenderer {
let previousConnection;
let previousCell;

const horizontalPartIntersectionsOffset = firstCellConnection.offset;
const horizontalPartIntersectionsOffset = firstCellConnection.xOffset;

const areCellsOnSameRow = cells.every((cell) => {
return cell.y === firstCell.y;
Expand Down Expand Up @@ -276,9 +276,9 @@ export class SnakeModePolymerBondRenderer extends BaseRenderer {
: 0
: xDirection;
const maxXOffset = cell.connections.reduce((max, connection) => {
return connection.isVertical || max > connection.offset
return connection.isVertical || max > connection.xOffset
? max
: connection.offset;
: connection.xOffset;
}, 0);

maxHorizontalOffset =
Expand All @@ -304,8 +304,8 @@ export class SnakeModePolymerBondRenderer extends BaseRenderer {
SMOOTH_CORNER_SIZE -
sin * (cellConnection.yOffset || 0) * 3 -
(isTwoNeighborRowsConnection
? maxHorizontalOffset - cellConnection.offset
: cellConnection.offset) *
? maxHorizontalOffset - cellConnection.xOffset
: cellConnection.xOffset) *
3
} `;
dAttributeForPath += generateBend(0, sin, cos, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ export class CanvasMatrix {
direction: number,
increaseOffset = (connection: Connection, increaseValue?: number) => {
if (isNumber(increaseValue)) {
connection.offset = increaseValue;
connection.xOffset = increaseValue;
} else {
connection.offset++;
connection.xOffset++;
}
},
getOffset = (connection: Connection) => connection.offset,
getOffset = (connection: Connection) => connection.xOffset,
) {
// set offsets for connections with overlappings
const currentConnections = new Map<PolymerBond, Set<Connection>>();
Expand Down Expand Up @@ -133,8 +133,8 @@ export class CanvasMatrix {
this.matrix.forEach((cell) => {
const biggestOffsetInCell = cell.connections.reduce(
(biggestOffset, connection) => {
return connection.offset > biggestOffset
? connection.offset
return connection.xOffset > biggestOffset
? connection.xOffset
: biggestOffset;
},
0,
Expand All @@ -144,12 +144,12 @@ export class CanvasMatrix {
if (connection.direction !== direction) {
return;
}
if (connection.offset <= biggestOffsetInCell) {
if (connection.xOffset <= biggestOffsetInCell) {
const polymerBondConnections = this.polymerBondToConnections.get(
connection.polymerBond,
);
polymerBondConnections?.forEach((polymerBondConnection) => {
polymerBondConnection.offset = biggestOffsetInCell;
polymerBondConnection.xOffset = biggestOffsetInCell;
});
handledConnections.add(connection.polymerBond);
}
Expand All @@ -164,7 +164,7 @@ export class CanvasMatrix {
return;
}

polymerBondConnection.offset++;
polymerBondConnection.xOffset++;
});
});
}
Expand Down Expand Up @@ -286,7 +286,7 @@ export class CanvasMatrix {
polymerBond,
connectedNode,
direction: isVertical ? 90 : xDirection,
offset: 0,
xOffset: 0,
yOffset: 0,
isVertical,
};
Expand All @@ -309,7 +309,7 @@ export class CanvasMatrix {
polymerBond,
connectedNode: null,
direction: xDirection,
offset: 0,
xOffset: 0,
yOffset: 0,
isVertical,
};
Expand All @@ -331,7 +331,7 @@ export class CanvasMatrix {
polymerBond,
connectedNode: null,
direction: yDirection,
offset: 0,
xOffset: 0,
yOffset: 0,
isVertical,
};
Expand All @@ -356,7 +356,7 @@ export class CanvasMatrix {
direction: isVertical
? yDirection
: { x: xDistance === 0 ? 0 : xDirection, y: yDirection },
offset: 0,
xOffset: 0,
yOffset: 0,
isVertical,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class Connection {
public readonly direction: 0 | 90 | 180 | 270 | { x: number; y: number },
public readonly isVertical: boolean,
public readonly polymerBond: PolymerBond,
public offset: number,
public xOffset: number,
public yOffset: number,
) {}
}

0 comments on commit 33540e3

Please sign in to comment.