Skip to content

Commit abe71c7

Browse files
committed
fix: enforce minimum constraints on snapped canvas dimensions in ResolutionMasterCanvas
- Ensure snapValue is always a positive number (≥1) via Number() coercion with Math.max(1, ...) guard to prevent zero/invalid snap divisor. - Compute minWidth/maxHeight from snap, manual_slider_min_w/h, and canvas_min_x/y so a snapped resize cannot go below any configured lower bound. - Extract snapDimension helper: rounds value to the nearest snap step and clamps it to the given minimum before passing to setDimensions.
1 parent 8059b87 commit abe71c7

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

js/ResolutionMaster.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,9 +2228,13 @@ class ResolutionMasterCanvas {
22282228
handleSnap() {
22292229
if (!this.validateWidgets()) return;
22302230

2231-
const snap = this.node.properties.snapValue;
2232-
const newWidth = Math.round(this.widthWidget.value / snap) * snap;
2233-
const newHeight = Math.round(this.heightWidget.value / snap) * snap;
2231+
const props = this.node.properties;
2232+
const snap = Math.max(1, Number(props.snapValue) || 1);
2233+
const minWidth = Math.max(1, snap, Number(props.manual_slider_min_w) || 1, Number(props.canvas_min_x) || 0);
2234+
const minHeight = Math.max(1, snap, Number(props.manual_slider_min_h) || 1, Number(props.canvas_min_y) || 0);
2235+
const snapDimension = (value, minValue) => Math.max(minValue, Math.round(value / snap) * snap);
2236+
const newWidth = snapDimension(this.widthWidget.value, minWidth);
2237+
const newHeight = snapDimension(this.heightWidget.value, minHeight);
22342238
this.setDimensions(newWidth, newHeight);
22352239
}
22362240

0 commit comments

Comments
 (0)