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

Skip to content

Commit e77dc3e

Browse files
committed
fix rotation error
* fix gridstack#2734 * this was introduced by another fix in 10.2.1
1 parent 7865592 commit e77dc3e

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
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+
- [10.3.0-dev (TBD)](#1030-dev-tbd)
89
- [10.3.0 (2024-06-26)](#1030-2024-06-26)
910
- [10.2.1 (2024-06-23)](#1021-2024-06-23)
1011
- [10.2.0 (2024-06-02)](#1020-2024-06-02)
@@ -112,6 +113,9 @@ Change log
112113

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

116+
## 10.3.0-dev (TBD)
117+
* fix: [#2734](https://github.com/gridstack/gridstack.js/bug/2734) rotate() JS error
118+
115119
## 10.3.0 (2024-06-26)
116120
* fix: [#2720](https://github.com/gridstack/gridstack.js/pull/2720) load() now creates widgets in order (used to be reverse due to old collision code)
117121

src/gridstack.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,10 @@ export class GridStack {
14471447
rot.x = n.x + pivotX - (n.h - (pivotY+1));
14481448
rot.y = (n.y + pivotY) - pivotX;
14491449
}
1450+
Object.keys(rot).forEach(k => { if (rot[k] === undefined) delete rot[k]; });
1451+
const _orig = n._orig;
14501452
this.update(el, rot);
1453+
n._orig = _orig; // restore as move() will delete it
14511454
});
14521455
return this;
14531456
}

src/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,10 @@ export class Utils {
590590
}
591591

592592
/** swap the given object 2 field values */
593-
public static swap(o: unknown, a: string, b: string): void { const tmp = o[a]; o[a] = o[b]; o[b] = tmp; }
593+
public static swap(o: unknown, a: string, b: string): void {
594+
if (!o) return;
595+
const tmp = o[a]; o[a] = o[b]; o[b] = tmp;
596+
}
594597

595598
/** returns true if event is inside the given element rectangle */
596599
// Note: Safari Mac has null event.relatedTarget which causes #1684 so check if DragEvent is inside the coordinates instead

0 commit comments

Comments
 (0)