8000 resize with sizeToContent · adumesny/gridstack.js@8d233b0 · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit 8d233b0

Browse files
committed
resize with sizeToContent
fix gridstack#2612 to allow resize when you have a number (soft max)
1 parent 03557d4 commit 8d233b0

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

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)
0