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
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,28 +75,28 @@
"devDependencies": {
"@rollup/plugin-terser": "^0.4.4",
"@types/jest": "^29.5.14",
"@types/node": "^22.15.30",
"@types/node": "^24.0.1",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^13.0.0",
"css-loader": "^7.1.2",
"eslint": "^9.27.0",
"eslint": "^9.29.0",
"globals": "^16.1.0",
"google-code-prettify": "^1.0.5",
"html-webpack-plugin": "^5.6.3",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest": "^30.0.0",
"jest-environment-jsdom": "^30.0.0",
"mini-css-extract-plugin": "^2.9.2",
"rimraf": "^6.0.1",
"rollup": "^4.42.0",
"rollup": "^4.43.0",
"rollup-plugin-ts": "^3.4.5",
"sass": "^1.89.0",
"sass": "^1.89.2",
"sass-loader": "^16.0.5",
"style-loader": "^4.0.0",
"ts-jest": "^29.3.4",
"ts-jest": "^29.4.0",
"ts-loader": "^9.5.2",
"tslib": "^2.8.1",
"typescript": "^5.8.3",
"typescript-eslint": "^8.33.1",
"typescript-eslint": "^8.34.0",
"webpack": "^5.99.9",
"webpack-cli": "^6.0.1",
"webpack-dev-server": "^5.2.2"
Expand Down
2,923 changes: 1,519 additions & 1,404 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,9 @@ export abstract class IsometricContainerAbstract extends IsometricElementAbstrac
}

public removeChildById(id: string): this {
const child = this.getChildById(id);
if (child) {
return this.removeChild(child);
}
return this.removeChild(
this.getChildById(id)
);
}

public setChildIndex(child: IsometricElementAbstract, index: number): this {
Expand Down Expand Up @@ -172,9 +171,7 @@ export abstract class IsometricContainerAbstract extends IsometricElementAbstrac
public bringChildForward(child: IsometricElementAbstract): this {
const childIndex = this.getChildIndex(child);
if (childIndex > -1) {
if (childIndex < this._children.length - 1) {
this.setChildIndex(child, childIndex + 1);
}
this.setChildIndex(child, childIndex + 1);
return this;
}
this.throwChildError();
Expand All @@ -192,9 +189,7 @@ export abstract class IsometricContainerAbstract extends IsometricElementAbstrac
public sendChildBackward(child: IsometricElementAbstract): this {
const childIndex = this.getChildIndex(child);
if (childIndex > -1) {
if (childIndex > 0) {
this.setChildIndex(child, childIndex - 1);
}
this.setChildIndex(child, childIndex - 1);
return this;
}
this.throwChildError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,8 @@ export abstract class IsometricDraggableAbstract extends IsometricElementAbstrac
if (typeof this._bounds === Typeof.UNDEFINED) {
this._bounds = false;
}
if (typeof this._dragStore === Typeof.UNDEFINED) {
this._dragStore = _dragStoreDefault;
}
if (typeof this._coords === Typeof.UNDEFINED) {
this._coords = {};
}
this._dragStore = _dragStoreDefault;
this._coords = {};
}

private betweenBounds(value: number, bounds: readonly [number, number]): number {
Expand Down Expand Up @@ -231,9 +227,7 @@ export abstract class IsometricDraggableAbstract extends IsometricElementAbstrac

event.preventDefault();

if (!this._dragging) {
this.dispatchEvent(DRAG_EVENT.DRAG_START);
}
this.dispatchEvent(DRAG_EVENT.DRAG_START);

this._dragging = true;

Expand Down Expand Up @@ -314,6 +308,8 @@ export abstract class IsometricDraggableAbstract extends IsometricElementAbstrac
this.setup();
}
this._drag = value;
// Tests work in jsdom environment so window will be always defined
/* istanbul ignore next */
if (_isBrowser) {
this.stopDrag();
this.beginDrag();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,9 @@ export abstract class IsometricGraphicAbstract extends IsometricElementAbstract

const property = getSVGProperty(animation.property);

if (!animation.element) {
animation.element = document.createElementNS(SVG_NAMESPACE, SVG_ELEMENTS.animate) as SVGAnimateElement;
}
animation.element = document.createElementNS(SVG_NAMESPACE, SVG_ELEMENTS.animate) as SVGAnimateElement;

if (!animation.element.parentNode) {
this.element.appendChild(animation.element);
}
this.element.appendChild(animation.element);

this.addAnimationBasicProperties(property, animation);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,27 +184,19 @@ export abstract class IsometricStarPolygonAbstract extends IsometricShapeAbstrac
rotation: this.rotation
};

if (Object.prototype.hasOwnProperty.call(props, animation.property)) {
const properties: Record<string, string> = getAnimationProperties(
this.getPentagramPath.bind(this),
animation,
props
);

const properties: Record<string, string> = getAnimationProperties(
this.getPentagramPath.bind(this),
animation,
props
);
animation.element = document.createElementNS(SVG_NAMESPACE, SVG_ELEMENTS.animate) as SVGAnimateElement;

if (!animation.element) {
animation.element = document.createElementNS(SVG_NAMESPACE, SVG_ELEMENTS.animate) as SVGAnimateElement;
}
this.element.appendChild(animation.element);

if (!animation.element.parentNode) {
this.element.appendChild(animation.element);
}
this.addAnimationBasicProperties('d', animation);

this.addAnimationBasicProperties('d', animation);

addSVGProperties(animation.element, properties);

}
addSVGProperties(animation.element, properties);

}

Expand Down
26 changes: 9 additions & 17 deletions src/@classes/public/IsometricCircle/IsometricCircle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,27 +127,19 @@ export class IsometricCircle extends IsometricShapeAbstract {
radius: this.radius
};

if (Object.prototype.hasOwnProperty.call(props, animation.property)) {

const properties: Record<string, string> = getAnimationProperties(
this.getCirclePath.bind(this),
animation,
props
);

if (!animation.element) {
animation.element = document.createElementNS(SVG_NAMESPACE, SVG_ELEMENTS.animate) as SVGAnimateElement;
}
const properties: Record<string, string> = getAnimationProperties(
this.getCirclePath.bind(this),
animation,
props
);

if (!animation.element.parentNode) {
this.element.appendChild(animation.element);
}
animation.element = document.createElementNS(SVG_NAMESPACE, SVG_ELEMENTS.animate) as SVGAnimateElement;

this.addAnimationBasicProperties('d', animation);
this.element.appendChild(animation.element);

addSVGProperties(animation.element, properties);
this.addAnimationBasicProperties('d', animation);

}
addSVGProperties(animation.element, properties);

}

Expand Down
39 changes: 17 additions & 22 deletions src/@classes/public/IsometricGroup/IsometricGroup.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { SVG_ELEMENTS } from '@constants';
import { uuid, getPointFromIsometricPoint } from '@utils/math';
import {
elementHasSVGParent,
addSVGProperties
} from '@utils/svg';
import { addSVGProperties } from '@utils/svg';
import { applyMixins } from '@utils/other';
import { IsometricContainerAbstract } from '@classes/abstract/IsometricContainerAbstract';
import { IsometricDraggableAbstract } from '@classes/abstract/IsometricDraggableAbstract';
Expand Down Expand Up @@ -31,24 +28,22 @@ export class IsometricGroup extends IsometricContainerAbstract {
protected props: IsometricGroupProps;

public override update(): this {
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})`
}
);
}
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
26 changes: 9 additions & 17 deletions src/@classes/public/IsometricRectangle/IsometricRectangle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,27 +99,19 @@ export class IsometricRectangle extends IsometricShapeAbstract {
height: this.height
};

if (Object.prototype.hasOwnProperty.call(props, animation.property)) {

const properties: Record<string, string> = getAnimationProperties(
this.getRectanglePath.bind(this),
animation,
props,
);

if (!animation.element) {
animation.element = document.createElementNS(SVG_NAMESPACE, SVG_ELEMENTS.animate) as SVGAnimateElement;
}
const properties: Record<string, string> = getAnimationProperties(
this.getRectanglePath.bind(this),
animation,
props,
);

if (!animation.element.parentNode) {
this.element.appendChild(animation.element);
}
animation.element = document.createElementNS(SVG_NAMESPACE, SVG_ELEMENTS.animate) as SVGAnimateElement;

this.addAnimationBasicProperties('d', animation);
this.element.appendChild(animation.element);

addSVGProperties(animation.element, properties);
this.addAnimationBasicProperties('d', animation);

}
addSVGProperties(animation.element, properties);

}

Expand Down
Loading