Skip to content

Commit 52ceb49

Browse files
authored
Merge pull request #3201 from adumesny/master
layoutsNodesChange() fix with neg values
2 parents 6ee4e73 + b378763 commit 52ceb49

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

doc/API.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,7 +2118,7 @@ cacheLayout(
21182118
clear): GridStackEngine;
21192119
```
21202120

2121-
Defined in: [gridstack-engine.ts:1196](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L1196)
2121+
Defined in: [gridstack-engine.ts:1199](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L1199)
21222122

21232123
call to cache the given layout internally to the given location so we can restore back when column changes size
21242124

@@ -2140,7 +2140,7 @@ call to cache the given layout internally to the given location so we can restor
21402140
cacheOneLayout(n, column): GridStackEngine;
21412141
```
21422142

2143-
Defined in: [gridstack-engine.ts:1216](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L1216)
2143+
Defined in: [gridstack-engine.ts:1219](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L1219)
21442144

21452145
call to cache the given node layout internally to the given location so we can restore back when column changes size
21462146

@@ -2182,7 +2182,7 @@ true if x,y or w,h are different after clamping to min/max
21822182
cleanupNode(node): GridStackEngine;
21832183
```
21842184

2185-
Defined in: [gridstack-engine.ts:1247](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L1247)
2185+
Defined in: [gridstack-engine.ts:1250](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L1250)
21862186

21872187
called to remove all internal values but the _id
21882188

@@ -2345,7 +2345,7 @@ Defined in: [gridstack-engine.ts:1002](https://github.com/adumesny/gridstack.js/
23452345
protected findCacheLayout(n, column): number;
23462346
```
23472347

2348-
Defined in: [gridstack-engine.ts:1230](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L1230)
2348+
Defined in: [gridstack-engine.ts:1233](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L1233)
23492349

23502350
###### Parameters
23512351

@@ -2668,7 +2668,7 @@ engine.removeNode(node, true, true);
26682668
removeNodeFromLayoutCache(n): void;
26692669
```
26702670

2671-
Defined in: [gridstack-engine.ts:1234](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L1234)
2671+
Defined in: [gridstack-engine.ts:1237](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L1237)
26722672

26732673
###### Parameters
26742674

doc/CHANGES.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +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-
- [12.4.0 (2025-11-26)](#1240-2025-11-26)
8+
- [12.4.0 (2025-12-12)](#1240-2025-12-12)
99
- [12.3.3 (2025-08-13)](#1233-2025-08-13)
1010
- [12.3.2 (2025-08-12)](#1232-2025-08-12)
1111
- [12.3.1 (2025-08-11)](#1231-2025-08-11)
@@ -135,11 +135,12 @@ Change log
135135

136136
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
137137

138-
## 12.4.0 (2025-11-26)
138+
## 12.4.0 (2025-12-12)
139139
* feat: [#3104](https://github.com/gridstack/gridstack.js/issues/3104) Custom resize div element target - thank you [Marvin Heilemann](https://github.com/muuvmuuv)
140140
* fix: [#3181](https://github.com/gridstack/gridstack.js/issues/3181) re-initing from DOM missing x:0, y:0 messing layout
141141
* fix: [#3191](https://github.com/gridstack/gridstack.js/pull/3191) touch issue on Linux
142142
* fix: [#3194](https://github.com/gridstack/gridstack.js/pull/3194) `updateOption()` update lazyLoad
143+
* fix: [#3200](https://github.com/gridstack/gridstack.js/pull/3200) updating higher column layout can cause negative values in `layoutsNodesChange()`
143144

144145
## 12.3.3 (2025-08-13)
145146
* fix: [#3139](https://github.com/gridstack/gridstack.js/pull/3139) `Utils:removeInternalForSave()` to skip arrays

src/gridstack-engine.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,14 +1061,17 @@ export class GridStackEngine {
10611061
// TODO: detect doing item 'swaps' will help instead of move (especially in 1 column mode)
10621062
if (n.y >= 0 && node.y !== node._orig.y) {
10631063
n.y += (node.y - node._orig.y);
1064+
if (n.y < 0) n.y = 0;
10641065
}
10651066
// X changed, scale from new position
10661067
if (node.x !== node._orig.x) {
10671068
n.x = Math.round(node.x * ratio);
1069+
if (n.x < 0) n.x = 0;
10681070
}
10691071
// width changed, scale from new width
10701072
if (node.w !== node._orig.w) {
10711073
n.w = Math.round(node.w * ratio);
1074+
if (n.w < 1) n.w = 1;
10721075
}
10731076
// ...height always carries over from cache
10741077
});

0 commit comments

Comments
 (0)