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

Skip to content

Commit 1834509

Browse files
authored
Merge pull request gridstack#2620 from adumesny/master
resize with sizeToContent
2 parents a68821d + 49210da commit 1834509

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

doc/CHANGES.md

Lines changed: 3 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.1.1 (2024-03-03)](#1011-2024-03-03)
89
- [10.1.0 (2024-02-04)](#1010-2024-02-04)
910
- [10.0.1 (2023-12-10)](#1001-2023-12-10)
1011
- [10.0.0 (2023-11-20)](#1000-2023-11-20)
@@ -106,6 +107,8 @@ Change log
106107
- [v0.1.0 (2014-11-18)](#v010-2014-11-18)
107108

108109
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
110+
## 10.1.1 (2024-03-03)
111+
* fix: [#2620](https://github.com/gridstack/gridstack.js/pull/2620) allow resizing with sizeToContent:NUMBER is uses
109112

110113
## 10.1.0 (2024-02-04)
111114
* feat: [#2574](https://github.com/gridstack/gridstack.js/pull/2574) Allow cell height in cm and mm units

src/dd-gridstack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class DDGridStack {
4646
if (handles === 'all') handles = 'n,e,s,w,se,sw,ne,nw';
4747
// NOTE: keep the resize handles as e,w don't have enough space (10px) to show resize corners anyway. limit during drag instead
4848
// restrict vertical resize if height is done to match content anyway... odd to have it spring back
49-
// if (Utils.shouldSizeToContent(n)) {
49+
// if (Utils.shouldSizeToContent(n, true)) {
5050
// const doE = handles.indexOf('e') !== -1;
5151
// const doW = handles.indexOf('w') !== -1;
5252
// handles = doE ? (doW ? 'e,w' : 'e') : (doW ? 'w' : '');

src/dd-resizable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
166166

167167
/** @internal */
168168
protected _resizeStart(event: MouseEvent): DDResizable {
169-
this.sizeToContent = Utils.shouldSizeToContent(this.el.gridstackNode);
169+
this.sizeToContent = Utils.shouldSizeToContent(this.el.gridstackNode, true); // strick true only and not number
170170
this.originalRect = this.el.getBoundingClientRect();
171171
this.scrollEl = Utils.getScrollElement(this.el);
172172
this.scrollY = this.scrollEl.scrollTop;

src/utils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ export class Utils {
109109
return els;
110110
}
111111

112-
/** true if we should resize to content */
113-
static shouldSizeToContent(n: GridStackNode | undefined): boolean {
114-
return n?.grid && (!!n.sizeToContent || (n.grid.opts.sizeToContent && n.sizeToContent !== false));
112+
/** true if we should resize to content. strict=true when only 'sizeToContent:true' and not a number which lets user adjust */
113+
static shouldSizeToContent(n: GridStackNode | undefined, strict = false): boolean {
114+
return n?.grid && (strict ?
115+
(n.sizeToContent === true || (n.grid.opts.sizeToContent === true && n.sizeToContent === undefined)) :
116+
(!!n.sizeToContent || (n.grid.opts.sizeToContent && n.sizeToContent !== false)));
115117
}
116118

117119
/** returns true if a and b overlap */

0 commit comments

Comments
 (0)