Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0d87d73

Browse files
authored
Merge pull request gridstack#1950 from adumesny/master
code cleanup
2 parents 939aef5 + e44adb5 commit 0d87d73

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/gridstack-engine.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ export class GridStackEngine {
524524
o.pack = true;
525525

526526
// simpler case: move item directly...
527-
if (!this.maxRow/* && !this._hasLocked*/) {
527+
if (!this.maxRow) {
528528
return this.moveNode(node, o);
529529
}
530530

@@ -543,17 +543,14 @@ export class GridStackEngine {
543543
});
544544
if (!clonedNode) return false;
545545

546-
let canMove = clone.moveNode(clonedNode, o);
547-
// if maxRow make sure we are still valid size
548-
if (this.maxRow && canMove) {
549-
canMove = (clone.getRow() <= this.maxRow);
550-
// turns out we can't grow, then see if we can swap instead (ex: full grid) if we're not resizing
551-
if (!canMove && !o.resizing) {
552-
let collide = this.collide(node, o);
553-
if (collide && this.swap(node, collide)) {
554-
this._notify();
555-
return true;
556-
}
546+
// make sure we are still valid size
547+
let canMove = clone.moveNode(clonedNode, o) && clone.getRow() <= this.maxRow;
548+
// turns out we can't grow, then see if we can swap instead (ex: full grid) if we're not resizing
549+
if (!canMove && !o.resizing) {
550+
let collide = this.collide(node, o);
551+
if (collide && this.swap(node, collide)) {
552+
this._notify();
553+
return true;
557554
}
558555
}
559556
if (!canMove) return false;
@@ -593,7 +590,7 @@ export class GridStackEngine {
593590

594591
/** true if x,y or w,h are different after clamping to min/max */
595592
public changedPosConstrain(node: GridStackNode, p: GridStackPosition): boolean {
596-
// make sure w,h are set
593+
// first make sure w,h are set for caller
597594
p.w = p.w || node.w;
598595
p.h = p.h || node.h;
599596
if (node.x !== p.x || node.y !== p.y) return true;

0 commit comments

Comments
 (0)