Skip to content

Commit bb5e0d6

Browse files
committed
handle minW resizing when column count is less
* fix gridstack#2676
1 parent 6b4ae89 commit bb5e0d6

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

demo/responsive.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ <h1>Responsive: by column size</h1>
4343
let count = 0;
4444
let items = [ // our initial 12 column layout loaded first so we can compare
4545
{x: 0, y: 0},
46-
{x: 1, y: 0, w: 2, h: 2},
46+
{x: 1, y: 0, w: 2, h: 2, minW: 4},
4747
{x: 4, y: 0, w: 2},
4848
{x: 1, y: 3, w: 4},
4949
{x: 5, y: 3, w: 2},

doc/CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Change log
55
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
66
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
77

8+
- [10.1.2-dev (TBD)](#1012-dev-tbd)
89
- [10.1.2 (2024-03-30)](#1012-2024-03-30)
910
- [10.1.1 (2024-03-03)](#1011-2024-03-03)
1011
- [10.1.0 (2024-02-04)](#1010-2024-02-04)
@@ -108,6 +109,10 @@ Change log
108109
- [v0.1.0 (2014-11-18)](#v010-2014-11-18)
109110

110111
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
112+
## 10.1.2-dev (TBD)
113+
* fix: [#2672](https://github.com/gridstack/gridstack.js/pull/2672) dropping into full grid JS error
114+
* fix: [#2676](https://github.com/gridstack/gridstack.js/issues/2676) handle minW resizing when column count is less
115+
111116
## 10.1.2 (2024-03-30)
112117
* fix: [#2628](https://github.com/gridstack/gridstack.js/issues/2628) `removeAll()` does not trigger Angular's ngOnDestroy
113118
* fix: [#2503](https://github.com/gridstack/gridstack.js/issues/2503) Drag and drop a widget on top of a locked widget - Thank you [JakubEleniuk](https://github.com/JakubEleniuk)

src/gridstack.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,11 +2470,11 @@ export class GridStack {
24702470
node._moving = true; // AFTER, mark as moving object (wanted fix location before)
24712471
}
24722472

2473-
// set the min/max resize info
2473+
// set the min/max resize info taking into account the column count and position (so we don't resize outside the grid)
24742474
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);
24752475
if (event.type === 'resizestart') {
2476-
dd.resizable(el, 'option', 'minWidth', cellWidth * (node.minW || 1))
2477-
.resizable(el, 'option', 'minHeight', cellHeight * (node.minH || 1));
2476+
dd.resizable(el, 'option', 'minWidth', cellWidth * Math.min(node.minW || 1, this.getColumn() - node.x))
2477+
.resizable(el, 'option', 'minHeight', cellHeight * Math.min(node.minH || 1, (this.opts.maxRow || Number.MAX_SAFE_INTEGER) - node.y));
24782478
if (node.maxW) { dd.resizable(el, 'option', 'maxWidth', cellWidth * node.maxW); }
24792479
if (node.maxH) { dd.resizable(el, 'option', 'maxHeight', cellHeight * node.maxH); }
24802480
}

0 commit comments

Comments
 (0)