Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ module.exports = {
rules: {
'indent': ['error', 2],
'max-len': ['error', 180],
'no-trailing-spaces': 'error',
'no-trailing-spaces': 1,
'prefer-const': 0,
'@typescript-eslint/ban-ts-comment': 0,
'max-len': 0
}
};
4 changes: 2 additions & 2 deletions src/gridstack-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ export class GridStackEngine {
if (column < prevColumn) this.cacheLayout(this.nodes, prevColumn);
this.batchUpdate(); // do this EARLY as it will call saveInitial() so we can detect where we started for _dirty and collision
let newNodes: GridStackNode[] = [];

// if we're going to 1 column and using DOM order (item passed in) rather than default sorting, then generate that layout
let domOrder = false;
if (column === 1 && nodes?.length) {
Expand Down Expand Up @@ -910,7 +910,7 @@ export class GridStackEngine {
delete node._orig; // make sure the commit doesn't try to restore things back to original
});
}

this.nodes.forEach(n => delete n._orig); // clear _orig before batch=false so it doesn't handle float=true restore
this.batchUpdate(false, !doCompact);
delete this._inColumnResize;
Expand Down
16 changes: 8 additions & 8 deletions src/gridstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ export class GridStack {
* re-layout grid items to reclaim any empty space. Options are:
* 'list' keep the widget left->right order the same, even if that means leaving an empty slot if things don't fit
* 'compact' might re-order items to fill any empty space
*
*
* doSort - 'false' to let you do your own sorting ahead in case you need to control a different order. (default to sort)
*/
public compact(layout: CompactOptions = 'compact', doSort = true): GridStack {
Expand Down Expand Up @@ -1264,7 +1264,7 @@ export class GridStack {
this.engine.endUpdate();
}

/**
/**
* Updates widget height to match the content height to avoid v-scrollbar or dead space.
* Note: this assumes only 1 child under resizeToContentParent='.grid-stack-item-content' (sized to gridItem minus padding) that is at the entire content size wanted.
* useAttrSize set to true if GridStackNode.h should be used instead of actual container height when we don't need to wait for animation to finish to get actual DOM heights
Expand Down Expand Up @@ -1294,7 +1294,7 @@ export class GridStack {
} else {
// NOTE: clientHeight & getBoundingClientRect() is undefined for text and other leaf nodes. use <div> container!
const child = item.firstElementChild;
if (!child) { console.log(`Error: resizeToContent() '${GridStack.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`); return; }
if (!child) { console.log(`Error: resizeToContent() '${GridStack.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`); return; }
wantedH = child.getBoundingClientRect().height || itemH;
}
if (itemH === wantedH) return;
Expand All @@ -1320,7 +1320,7 @@ export class GridStack {
if (GridStack.resizeToContentCB) GridStack.resizeToContentCB(el, useAttr);
else this.resizeToContent(el, useAttr);
}

/**
* 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).
* @param value margin value
Expand Down Expand Up @@ -1678,10 +1678,10 @@ export class GridStack {
private doContentResize(delay = true, useAttr = false, n: GridStackNode = undefined) {
// update any gridItem height with sizeToContent, but wait for DOM $animation_speed to settle if we changed column count
// 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 ?
setTimeout(() => {
if (n) {
setTimeout(() => {
if (n) {
if (Utils.shouldSizeToContent(n)) this.resizeToContentCheck(n.el, useAttr);
} else if (this.engine.nodes.some(n => Utils.shouldSizeToContent(n))) {
} else if (this.engine.nodes.some(n => Utils.shouldSizeToContent(n))) {
const nodes = [...this.engine.nodes]; // in case order changes while resizing one
this.batchUpdate();
nodes.forEach(n => {
Expand All @@ -1703,7 +1703,7 @@ export class GridStack {

if (!forceRemove && trackSize && !this.resizeObserver) {
this._sizeThrottle = Utils.throttle(() => this.onResize(), this.opts.cellHeightThrottle);
this.resizeObserver = new ResizeObserver(entries => this._sizeThrottle());
this.resizeObserver = new ResizeObserver(() => this._sizeThrottle());
this.resizeObserver.observe(this.el);
this._skipInitialResize = true; // makeWidget will originally have called on startup
} else if ((forceRemove || !trackSize) && this.resizeObserver) {
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const dragInDefaultOptions: DDDragInOpt = {
// scroll: false,
};

/**
/**
* different layout options when changing # of columns, including a custom function that takes new/old column count, and array of new/old positions
* Note: new list may be partially already filled if we have a cache of the layout at that size and new items were added later.
* Options are:
Expand Down Expand Up @@ -321,7 +321,7 @@ export interface GridStackWidget extends GridStackPosition {
id?: string;
/** html to append inside as content */
content?: string;
/** local (vs grid) override - see GridStackOptions.
/** local (vs grid) override - see GridStackOptions.
* Note: This also allow you to set a maximum h value (but user changeable during normal resizing) to prevent unlimited content from taking too much space (get scrollbar) */
sizeToContent?: boolean | number;
/** local override of GridStack.resizeToContentParent that specify the class to use for the parent (actual) vs child (wanted) height */
Expand Down