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

Skip to content

Commit c0d4de3

Browse files
authored
Merge pull request gridstack#1769 from adumesny/master
destroy(false) doesn't force static grid
2 parents 1b3b1db + f7b774e commit c0d4de3

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

doc/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Change log
6262
* fix [#1760](https://github.com/gridstack/gridstack.js/issues/1760) `removable:true` working again (broke in 4.x)
6363
* fix [#1761](https://github.com/gridstack/gridstack.js/issues/1761) `staticGrid(false)` will now enable drag in behavior (if set)
6464
* fix [#1767](https://github.com/gridstack/gridstack.js/issues/1767) `locked` item can be user moved/resized again, just not pushed by other nodes (broke in 1.1.1)
65+
* fix [#1764](https://github.com/gridstack/gridstack.js/issues/1764) `destroy(false)` can now re-init properly (doesn't force static grid)
6566

6667
## 4.2.3 (2021-5-8)
6768

src/gridstack.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -718,14 +718,16 @@ export class GridStack {
718718
public destroy(removeDOM = true): GridStack {
719719
if (!this.el) return; // prevent multiple calls
720720
this._updateWindowResizeEvent(true);
721-
this.setStatic(true); // permanently removes DD
721+
this.setStatic(true, false); // permanently removes DD but don't set CSS class (we're going away)
722+
this.setAnimation(false);
722723
if (!removeDOM) {
723724
this.removeAll(removeDOM);
724725
this.el.classList.remove(this.opts._styleSheetClass);
725726
} else {
726727
this.el.parentNode.removeChild(this.el);
727728
}
728729
this._removeStylesheet();
730+
this.el.removeAttribute('gs-current-row');
729731
delete this.opts._isNested;
730732
delete this.opts;
731733
delete this._placeholder;
@@ -948,13 +950,13 @@ export class GridStack {
948950
* Also toggle the grid-stack-static class.
949951
* @param val if true the grid become static.
950952
*/
951-
public setStatic(val: boolean): GridStack {
953+
public setStatic(val: boolean, updateClass = true): GridStack {
952954
if (this.opts.staticGrid === val) return this;
953955
this.opts.staticGrid = val;
954956
this._setupRemoveDrop();
955957
this._setupAcceptWidget();
956958
this.engine.nodes.forEach(n => this._prepareDragDropByNode(n)); // either delete or init Drag&drop
957-
this._setStaticClass();
959+
if (updateClass) { this._setStaticClass(); }
958960
return this;
959961
}
960962

0 commit comments

Comments
 (0)