Skip to content

Commit e5fd01c

Browse files
committed
fix(canvas): NaN-safe guards on uniform-2D anchor checks
1 parent 0c16192 commit e5fd01c

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎src/components/Canvas/hooks/useKonvaTransformer.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function commitUniformModuleResize({
6969
dpmm,
7070
}: UniformResizeArgs): ObjectChanges {
7171
const current = (obj.props as unknown as Record<string, number>)[spec.name];
72-
if (typeof current !== "number" || current <= 0)
72+
if (typeof current !== "number" || !(current > 0))
7373
return { ...fallbackPos, props: {} };
7474
const newModules = computeNewModules(
7575
current,

‎src/components/Canvas/transformerGeometry.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export function applyUniformModuleSnap(
129129
newBox: BoundingBox,
130130
anchor: TransformAnchor | null,
131131
): BoundingBox {
132-
if (anchor?.kind !== "uniformModule" || anchor.nodeSize <= 0 || anchor.modules <= 0) {
132+
if (anchor?.kind !== "uniformModule" || !(anchor.nodeSize > 0) || !(anchor.modules > 0)) {
133133
return newBox;
134134
}
135135
const scale = newBox.width / anchor.nodeSize;

0 commit comments

Comments
 (0)