Skip to content

Commit 3c2d242

Browse files
authored
Merge pull request #1874 from adumesny/master
#1868 prevent swap during resize
2 parents 37a7c67 + e8b5e14 commit 3c2d242

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

doc/CHANGES.md

Lines changed: 4 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+
- [4.3.0-dev (TBD)](#430-dev-tbd)
89
- [4.3.0 (2021-10-15)](#430-2021-10-15)
910
- [4.2.7 (2021-9-12)](#427-2021-9-12)
1011
- [4.2.6 (2021-7-11)](#426-2021-7-11)
@@ -62,6 +63,9 @@ Change log
6263

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

66+
## 4.3.0-dev (TBD)
67+
* fix [#1868](https://github.com/gridstack/gridstack.js/issues/1868) prevent swap during resize
68+
6569
## 4.3.0 (2021-10-15)
6670
* you can now swap items of different width if they are the same row/height. Thanks to [spektrummedia](http://spektrummedia.com) for sponsoring it.
6771
* fix [#1860](https://github.com/gridstack/gridstack.js/issues/1860) nested grid save inf loop fix

src/gridstack-dd.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ GridStack.prototype._dragOrResize = function(this: GridStack, el: GridItemHTMLEl
594594
w: (ui.size ? ui.size.width : node.w * cellWidth) - mLeft - mRight,
595595
h: (ui.size ? ui.size.height : node.h * cellHeight) - mTop - mBottom
596596
};
597-
if (this.engine.moveNodeCheck(node, {...p, cellWidth, cellHeight, rect})) {
597+
if (this.engine.moveNodeCheck(node, {...p, cellWidth, cellHeight, rect, resizing})) {
598598
node._lastUiPosition = ui.position;
599599
this.engine.cacheRects(cellWidth, cellHeight, mTop, mRight, mBottom, mLeft);
600600
delete node._skipDown;

src/gridstack-engine.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,8 @@ export class GridStackEngine {
537537
// if maxRow make sure we are still valid size
538538
if (this.maxRow && canMove) {
539539
canMove = (clone.getRow() <= this.maxRow);
540-
// turns out we can't grow, then see if we can swap instead (ex: full grid)
541-
if (!canMove) {
540+
// turns out we can't grow, then see if we can swap instead (ex: full grid) if we're not resizing
541+
if (!canMove && !o.resizing) {
542542
let collide = this.collide(node, o);
543543
if (collide && this.swap(node, collide)) {
544544
this._notify();

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ export interface GridStackMoveOpts extends GridStackPosition {
210210
marginRight?: number;
211211
/** position in pixels of the currently dragged items (for overlap check) */
212212
rect?: GridStackPosition;
213+
/** true if we're live resizing */
214+
resizing?: boolean;
213215
}
214216

215217
export interface GridStackPosition {

0 commit comments

Comments
 (0)