From fec86f245b37034145a2779171750ebeb66cd5dc Mon Sep 17 00:00:00 2001 From: Alain Dumesny Date: Thu, 13 Jun 2024 11:25:59 +0200 Subject: [PATCH] check for fixed grid maxRow during resize * fix for #2683 untested as I don't have my dev machine right now. --- doc/CHANGES.md | 4 ++++ src/gridstack.ts | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/CHANGES.md b/doc/CHANGES.md index f586ac951..28b6a8ae5 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -109,6 +109,10 @@ Change log - [v0.1.0 (2014-11-18)](#v010-2014-11-18) + +## 10.2.0-dev (TBD) +* fix: [#2683](https://github.com/gridstack/gridstack.js/issues/2683) check for fixed grid maxRow during resize + ## 10.2.0 (2024-06-02) * feat: [#2682](https://github.com/gridstack/gridstack.js/pull/2682) You can now press 'Esc' to cancel a move|resize, 'r' to rotate during a drag. added `GridStack.rotate()` as well - Thank you John B. for this feature sponsor. * fix: [#2672](https://github.com/gridstack/gridstack.js/pull/2672) dropping into full grid JS error diff --git a/src/gridstack.ts b/src/gridstack.ts index d41c3f3d3..8060c7834 100644 --- a/src/gridstack.ts +++ b/src/gridstack.ts @@ -2503,10 +2503,12 @@ export class GridStack { // set the min/max resize info taking into account the column count and position (so we don't resize outside the grid) this.engine.cacheRects(cellWidth, cellHeight, this.opts.marginTop as number, this.opts.marginRight as number, this.opts.marginBottom as number, this.opts.marginLeft as number); if (event.type === 'resizestart') { - dd.resizable(el, 'option', 'minWidth', cellWidth * Math.min(node.minW || 1, this.getColumn() - node.x)) - .resizable(el, 'option', 'minHeight', cellHeight * Math.min(node.minH || 1, (this.opts.maxRow || Number.MAX_SAFE_INTEGER) - node.y)); - if (node.maxW) { dd.resizable(el, 'option', 'maxWidth', cellWidth * node.maxW); } - if (node.maxH) { dd.resizable(el, 'option', 'maxHeight', cellHeight * node.maxH); } + const colLeft = this.getColumn() - node.x; + const rowLeft = (this.opts.maxRow || Number.MAX_SAFE_INTEGER) - node.y; + dd.resizable(el, 'option', 'minWidth', cellWidth * Math.min(node.minW || 1, colLeft)) + .resizable(el, 'option', 'minHeight', cellHeight * Math.min(node.minH || 1, rowLeft)) + .resizable(el, 'option', 'maxWidth', cellWidth * Math.min(node.maxW || Number.MAX_SAFE_INTEGER, colLeft)) + .resizable(el, 'option', 'maxHeight', cellHeight * Math.min(node.maxH || Number.MAX_SAFE_INTEGER, rowLeft)); } }