Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [3.11.2] - 2025-09-24

- Avoid updating a group that has not been added to a canvas. This will avoid an error if a property is set before the group has been added to a canvas.

## [3.11.1] - 2025-01-01

- Created a utility to build animation properties and refactored the classes to make use of this utility to avoid code repetition
Expand Down
36 changes: 19 additions & 17 deletions src/@classes/public/IsometricGroup/IsometricGroup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SVG_ELEMENTS } from '@constants';
import { uuid, getPointFromIsometricPoint } from '@utils/math';
import { addSVGProperties } from '@utils/svg';
import { addSVGProperties, elementHasSVGParent } from '@utils/svg';
import { applyMixins } from '@utils/other';
import { IsometricContainerAbstract } from '@classes/abstract/IsometricContainerAbstract';
import { IsometricDraggableAbstract } from '@classes/abstract/IsometricDraggableAbstract';
Expand Down Expand Up @@ -28,22 +28,24 @@ export class IsometricGroup extends IsometricContainerAbstract {
protected props: IsometricGroupProps;

public override update(): this {
const point = getPointFromIsometricPoint(
0,
0,
{
r: this.props.right,
l: this.props.left,
t: this.props.top
},
this.data.scale
);
addSVGProperties(
this.element,
{
transform: `translate(${point.x}, ${point.y})`
}
);
if (elementHasSVGParent(this.element)) {
const point = getPointFromIsometricPoint(
0,
0,
{
r: this.props.right,
l: this.props.left,
t: this.props.top
},
this.data.scale
);
addSVGProperties(
this.element,
{
transform: `translate(${point.x}, ${point.y})`
}
);
}
return super.update();
}

Expand Down
10 changes: 10 additions & 0 deletions tests/properties.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,4 +649,14 @@ describe('Test properties', (): void => {

});

it('IsometricGroup properties without being adding to canvas', () => {
const group = new IsometricGroup();
group.top = 1;
group.right = 0.5;
group.left = 2;
expect(group.top).toBe(1);
expect(group.right).toBe(0.5);
expect(group.left).toBe(2);
});

});