You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* fix#404
* added `GridStackOptions.fitToContent` and `GridStackWidget.fitToContent` to make gridItems size themselves to their content (no scroll bar), calling `GridStack.resizeToContent(el)` whenever the grid or item is resized
* added demo showing behavior
* fixed sizing event to use much more accurate ResizeObserver on grid rather than generic window.addEventListener('resize')
Copy file name to clipboardExpand all lines: doc/CHANGES.md
+6-2Lines changed: 6 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,8 @@ Change log
5
5
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
6
6
**Table of Contents***generated with [DocToc](http://doctoc.herokuapp.com/)*
7
7
8
-
-[8.4.0-dev (2023-07-20)](#840-2023-07-20)
8
+
-[8.4.0-dev (TBD)](#840-dev-tbd)
9
+
-[8.4.0 (2023-07-20)](#840-2023-07-20)
9
10
-[8.3.0 (2023-06-13)](#830-2023-06-13)
10
11
-[8.2.3 (2023-06-11)](#823-2023-06-11)
11
12
-[8.2.1 (2023-05-26)](#821-2023-05-26)
@@ -92,7 +93,10 @@ Change log
92
93
93
94
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
94
95
95
-
## 8.4.0-dev (2023-07-20)
96
+
## 8.4.0-dev (TBD)
97
+
- feat [#404](https://github.com/gridstack/gridstack.js/issues/404) added `GridStackOptions.fitToContent` and `GridStackWidget.fitToContent` to make gridItems size themselves to their content (no scroll bar), calling `GridStack.resizeToContent(el)` whenever the grid or item is resized.
98
+
99
+
## 8.4.0 (2023-07-20)
96
100
* feat [#2378](https://github.com/gridstack/gridstack.js/pull/2378) attribute `DDRemoveOpt.decline` to deny the removal of a specific class.
97
101
* fix: dragging onto trash now calls removeWidget() and therefore `GridStack.addRemoveCB` (for component cleanup)
98
102
* feat: `load()` support re-order loading without explicit coordinates (`autoPosition` or missing `x,y`) uses passed order.
-`handleClass` - draggable handle class (e.g. `'grid-stack-item-content'`). If set `handle` is ignored (default: `null`)
@@ -158,6 +159,7 @@ You need to add `noResize` and `noMove` attributes to completely lock the widget
158
159
-`noMove` - disable element moving
159
160
-`id`- (number | string) good for quick identification (for example in change event)
160
161
-`content` - (string) html content to be added when calling `grid.load()/addWidget()` as content inside the item
162
+
-`fitToContent` - make gridItem size itself to the content, calling `GridStack.resizeToContent(el)` whenever the grid or item is resized.
161
163
-`subGrid`?: GridStackOptions - optional nested grid options and list of children
162
164
-`subGridDynamic`?: boolean - enable/disable the creation of sub-grids on the fly by dragging items completely over others (nest) vs partially (push). Forces `DDDragOpt.pause=true` to accomplish that.
constwantedH=(item.firstChildasElement)?.clientHeight||itemH;// NOTE: clientHeight & getBoundingClientRect() is undefined for text and other leaf nodes. use <div> container!
1266
+
if(itemH===wantedH)return;
1267
+
height+=wantedH-itemH;
1268
+
constcell=this.getCellHeight();
1269
+
if(!cell)return;
1270
+
leth=Math.ceil(height/cell);
1271
+
if(n.maxH&&h>n.maxH)h=n.maxH;
1272
+
if(h!==n.h)this.moveNode(n,{h});
1273
+
});
1274
+
}
1275
+
1248
1276
/**
1249
1277
* Updates the margins which will set all 4 sides at once - see `GridStackOptions.margin` for format options (CSS string format of 1,2,4 values or single number).
// immediate update if we've changed column count or have no threshold
1577
-
this.cellHeight();
1578
-
}
1579
-
}
1602
+
if(this._isAutoCellHeight)this.cellHeight();
1580
1603
1581
-
// finally update any nested grids
1604
+
// update any nested grids, or items size
1582
1605
this.engine.nodes.forEach(n=>{
1583
-
if(n.subGrid)n.subGrid.onParentResize()
1606
+
if(n.subGrid)n.subGrid.onResize()
1607
+
// update any gridItem height with fitToContent, but wait for DOM $animation_speed to settle if we changed column count
1608
+
// TODO: is there a way to know what the final (post animation) size of the content will be so we can animate the column width and height together rather than sequentially ?
/** the type of engine to create (so you can subclass) default to GridStackEngine */
162
162
engineClass?: typeofGridStackEngine;
163
163
164
+
/** set to true if all grid items (by default, but item can also override) height should be based on content size instead of WidgetItem.h to avoid v-scrollbars.
165
+
Note: this is still row based, not pixels, so it will use ceil(getBoundingClientRect().height / getCellHeight()) */
166
+
fitToContent?: boolean;
167
+
164
168
/** enable floating widgets (default?: false) See example (http://gridstack.github.io/gridstack.js/demo/float.html) */
0 commit comments