diff --git a/docs/api/index.md b/docs/api/index.md new file mode 100644 index 000000000..d71a080e9 --- /dev/null +++ b/docs/api/index.md @@ -0,0 +1,5222 @@ +# gridstack v12.2.2-dev + +## Classes + + +## Table of Contents + +- [GridStack](#gridstack) +- [GridStackEngine](#gridstackengine) +- [Utils](#utils) +- [GridStackOptions](#gridstackoptions) +- [`abstract` DDBaseImplement](#abstract-ddbaseimplement) +- [DDDraggable](#dddraggable) +- [DDDroppable](#dddroppable) +- [DDElement](#ddelement) +- [DDGridStack](#ddgridstack) +- [DDManager](#ddmanager) +- [DDResizable](#ddresizable-1) +- [DDResizableHandle](#ddresizablehandle) +- [Breakpoint](#breakpoint) +- [CellPosition](#cellposition) +- [DDDragOpt](#dddragopt) +- [DDDroppableOpt](#dddroppableopt) +- [DDElementHost](#ddelementhost) +- [DDRemoveOpt](#ddremoveopt) +- [DDResizableHandleOpt](#ddresizablehandleopt) +- [DDResizableOpt](#ddresizableopt) +- [DDResizeOpt](#ddresizeopt) +- [DDUIData](#dduidata) +- [DragTransform](#dragtransform) +- [GridHTMLElement](#gridhtmlelement) +- [GridItemHTMLElement](#griditemhtmlelement) +- [GridStackEngineOptions](#gridstackengineoptions) +- [GridStackMoveOpts](#gridstackmoveopts) +- [GridStackNode](#gridstacknode-2) +- [GridStackPosition](#gridstackposition) +- [GridStackWidget](#gridstackwidget) +- [HeightData](#heightdata) +- [HTMLElementExtendOpt\](#htmlelementextendoptt) +- [MousePosition](#mouseposition) +- [Position](#position-1) +- [Rect](#rect-1) +- [Responsive](#responsive) +- [Size](#size-1) +- [gridDefaults](#griddefaults) +- [AddRemoveFcn()](#addremovefcn) +- [ColumnOptions](#columnoptions) +- [CompactOptions](#compactoptions) +- [DDCallback()](#ddcallback) +- [DDDropOpt](#dddropopt) +- [DDKey](#ddkey) +- [DDOpts](#ddopts) +- [DDValue](#ddvalue) +- [EventCallback()](#eventcallback) +- [GridStackDroppedHandler()](#gridstackdroppedhandler) +- [GridStackElement](#gridstackelement) +- [GridStackElementHandler()](#gridstackelementhandler) +- [GridStackEvent](#gridstackevent) +- [GridStackEventHandler()](#gridstackeventhandler) +- [GridStackEventHandlerCallback](#gridstackeventhandlercallback) +- [GridStackNodesHandler()](#gridstacknodeshandler) +- [numberOrString](#numberorstring) +- [RenderFcn()](#renderfcn) +- [ResizeToContentFcn()](#resizetocontentfcn) +- [SaveFcn()](#savefcn) + + +### GridStack + +Defined in: [gridstack.ts:76](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L76) + +Main gridstack class - you will need to call `GridStack.init()` first to initialize your grid. +Note: your grid elements MUST have the following classes for the CSS layout to work: + +#### Example + +```ts +
+
+
Item 1
+
+
+``` + +#### Constructors + +##### Constructor + +```ts +new GridStack(el, opts): GridStack; +``` + +Defined in: [gridstack.ts:263](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L263) + +Construct a grid item from the given element and options + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `el` | [`GridHTMLElement`](#gridhtmlelement) | the HTML element tied to this grid after it's been initialized | +| `opts` | [`GridStackOptions`](#gridstackoptions) | grid options - public for classes to access, but use methods to modify! | + +###### Returns + +[`GridStack`](#gridstack-1) + +#### Methods + +##### \_updateResizeEvent() + +```ts +protected _updateResizeEvent(forceRemove): GridStack; +``` + +Defined in: [gridstack.ts:1829](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1829) + +add or remove the grid element size event handler + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `forceRemove` | `boolean` | `false` | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### \_widthOrContainer() + +```ts +protected _widthOrContainer(forBreakpoint): number; +``` + +Defined in: [gridstack.ts:887](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L887) + +return our expected width (or parent) , and optionally of window for dynamic column check + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `forBreakpoint` | `boolean` | `false` | + +###### Returns + +`number` + +##### addGrid() + +```ts +static addGrid(parent, opt): GridStack; +``` + +Defined in: [gridstack.ts:141](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L141) + +call to create a grid with the given options, including loading any children from JSON structure. This will call GridStack.init(), then +grid.load() on any passed children (recursively). Great alternative to calling init() if you want entire grid to come from +JSON serialized data, including options. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `parent` | `HTMLElement` | HTML element parent to the grid | +| `opt` | [`GridStackOptions`](#gridstackoptions) | grids options used to initialize the grid, and list of children | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### addWidget() + +```ts +addWidget(w): GridItemHTMLElement; +``` + +Defined in: [gridstack.ts:429](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L429) + +add a new widget and returns it. + +Widget will be always placed even if result height is more than actual grid height. +You need to use `willItFit()` before calling addWidget for additional check. +See also `makeWidget(el)` for DOM element. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `w` | [`GridStackWidget`](#gridstackwidget) | GridStackWidget definition. used MakeWidget(el) if you have dom element instead. | + +###### Returns + +[`GridItemHTMLElement`](#griditemhtmlelement) + +###### Example + +```ts +const grid = GridStack.init(); +grid.addWidget({w: 3, content: 'hello'}); +``` + +##### batchUpdate() + +```ts +batchUpdate(flag): GridStack; +``` + +Defined in: [gridstack.ts:792](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L792) + +use before calling a bunch of `addWidget()` to prevent un-necessary relayouts in between (more efficient) +and get a single event callback. You will see no changes until `batchUpdate(false)` is called. + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `flag` | `boolean` | `true` | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### cellHeight() + +```ts +cellHeight(val?): GridStack; +``` + +Defined in: [gridstack.ts:849](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L849) + +Update current cell height - see `GridStackOptions.cellHeight` for format. +This method rebuilds an internal CSS style sheet. +Note: You can expect performance issues if call this method too often. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `val?` | [`numberOrString`](#numberorstring) | the cell height. If not passed (undefined), cells content will be made square (match width minus margin), if pass 0 the CSS will be generated by the application instead. | + +###### Returns + +[`GridStack`](#gridstack-1) + +###### Example + +```ts +grid.cellHeight(100); // same as 100px +grid.cellHeight('70px'); +grid.cellHeight(grid.cellWidth() * 1.2); +``` + +##### cellWidth() + +```ts +cellWidth(): number; +``` + +Defined in: [gridstack.ts:883](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L883) + +Gets current cell width. + +###### Returns + +`number` + +##### checkDynamicColumn() + +```ts +protected checkDynamicColumn(): boolean; +``` + +Defined in: [gridstack.ts:893](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L893) + +checks for dynamic column count for our current size, returning true if changed + +###### Returns + +`boolean` + +##### column() + +```ts +column(column, layout): GridStack; +``` + +Defined in: [gridstack.ts:937](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L937) + +set the number of columns in the grid. Will update existing widgets to conform to new number of columns, +as well as cache the original layout so you can revert back to previous positions without loss. + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `column` | `number` | `undefined` | Integer > 0 (default 12). | +| `layout` | [`ColumnOptions`](#columnoptions) | `'moveScale'` | specify the type of re-layout that will happen (position, size, etc...). Note: items will never be outside of the current column boundaries. default ('moveScale'). Ignored for 1 column | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### commit() + +```ts +commit(): GridStack; +``` + +Defined in: [gridstack.ts:2676](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L2676) + +###### Returns + +[`GridStack`](#gridstack-1) + +##### compact() + +```ts +compact(layout, doSort): GridStack; +``` + +Defined in: [gridstack.ts:924](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L924) + +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) + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `layout` | [`CompactOptions`](#compactoptions) | `'compact'` | +| `doSort` | `boolean` | `true` | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### createWidgetDivs() + +```ts +createWidgetDivs(n): HTMLElement; +``` + +Defined in: [gridstack.ts:467](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L467) + +create the default grid item divs, and content (possibly lazy loaded) by using GridStack.renderCB() + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `n` | [`GridStackNode`](#gridstacknode-2) | + +###### Returns + +`HTMLElement` + +##### destroy() + +```ts +destroy(removeDOM): GridStack; +``` + +Defined in: [gridstack.ts:984](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L984) + +Destroys a grid instance. DO NOT CALL any methods or access any vars after this as it will free up members. + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `removeDOM` | `boolean` | `true` | if `false` grid and items HTML elements will not be removed from the DOM (Optional. Default `true`). | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### disable() + +```ts +disable(recurse): GridStack; +``` + +Defined in: [gridstack.ts:1987](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1987) + +Temporarily disables widgets moving/resizing. +If you want a more permanent way (which freezes up resources) use `setStatic(true)` instead. +Note: no-op for static grid +This is a shortcut for: + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `recurse` | `boolean` | `true` | true (default) if sub-grids also get updated | + +###### Returns + +[`GridStack`](#gridstack-1) + +###### Example + +```ts +grid.enableMove(false); + grid.enableResize(false); +``` + +##### enable() + +```ts +enable(recurse): GridStack; +``` + +Defined in: [gridstack.ts:2003](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L2003) + +Re-enables widgets moving/resizing - see disable(). +Note: no-op for static grid. +This is a shortcut for: + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `recurse` | `boolean` | `true` | true (default) if sub-grids also get updated | + +###### Returns + +[`GridStack`](#gridstack-1) + +###### Example + +```ts +grid.enableMove(true); + grid.enableResize(true); +``` + +##### enableMove() + +```ts +enableMove(doEnable, recurse): GridStack; +``` + +Defined in: [gridstack.ts:2015](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L2015) + +Enables/disables widget moving. No-op for static grids, and locally defined items still overrule + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `doEnable` | `boolean` | `undefined` | - | +| `recurse` | `boolean` | `true` | true (default) if sub-grids also get updated | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### enableResize() + +```ts +enableResize(doEnable, recurse): GridStack; +``` + +Defined in: [gridstack.ts:2029](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L2029) + +Enables/disables widget resizing. No-op for static grids. + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `doEnable` | `boolean` | `undefined` | - | +| `recurse` | `boolean` | `true` | true (default) if sub-grids also get updated | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### float() + +```ts +float(val): GridStack; +``` + +Defined in: [gridstack.ts:1010](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1010) + +enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `val` | `boolean` | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### getCellFromPixel() + +```ts +getCellFromPixel(position, useDocRelative): CellPosition; +``` + +Defined in: [gridstack.ts:1034](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1034) + +Get the position of the cell under a pixel on screen. + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `position` | [`MousePosition`](#mouseposition) | `undefined` | the position of the pixel to resolve in absolute coordinates, as an object with top and left properties | +| `useDocRelative` | `boolean` | `false` | if true, value will be based on document position vs parent position (Optional. Default false). Useful when grid is within `position: relative` element Returns an object with properties `x` and `y` i.e. the column and row in the grid. | + +###### Returns + +[`CellPosition`](#cellposition) + +##### getCellHeight() + +```ts +getCellHeight(forcePixel): number; +``` + +Defined in: [gridstack.ts:806](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L806) + +Gets current cell height. + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `forcePixel` | `boolean` | `false` | + +###### Returns + +`number` + +##### getColumn() + +```ts +getColumn(): number; +``` + +Defined in: [gridstack.ts:969](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L969) + +get the number of columns in the grid (default 12) + +###### Returns + +`number` + +##### getDD() + +```ts +static getDD(): DDGridStack; +``` + +Defined in: [gridstack.ts:1918](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1918) + +get the global (but static to this code) DD implementation + +###### Returns + +[`DDGridStack`](#ddgridstack) + +##### getFloat() + +```ts +getFloat(): boolean; +``` + +Defined in: [gridstack.ts:1021](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1021) + +get the current float mode + +###### Returns + +`boolean` + +##### getGridItems() + +```ts +getGridItems(): GridItemHTMLElement[]; +``` + +Defined in: [gridstack.ts:972](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L972) + +returns an array of grid HTML elements (no placeholder) - used to iterate through our children in DOM order + +###### Returns + +[`GridItemHTMLElement`](#griditemhtmlelement)[] + +##### getMargin() + +```ts +getMargin(): number; +``` + +Defined in: [gridstack.ts:1526](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1526) + +returns current margin number value (undefined if 4 sides don't match) + +###### Returns + +`number` + +##### getRow() + +```ts +getRow(): number; +``` + +Defined in: [gridstack.ts:1055](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1055) + +returns the current number of rows, which will be at least `minRow` if set + +###### Returns + +`number` + +##### init() + +```ts +static init(options, elOrString): GridStack; +``` + +Defined in: [gridstack.ts:91](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L91) + +initializing the HTML element, or selector string, into a grid will return the grid. Calling it again will +simply return the existing instance (ignore any passed options). There is also an initAll() version that support +multiple grids initialization at once. Or you can use addGrid() to create the entire grid from JSON. + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `options` | [`GridStackOptions`](#gridstackoptions) | `{}` | grid options (optional) | +| `elOrString` | [`GridStackElement`](#gridstackelement) | `'.grid-stack'` | element or CSS selector (first one used) to convert to a grid (default to '.grid-stack' class selector) | + +###### Returns + +[`GridStack`](#gridstack-1) + +###### Example + +```ts +const grid = GridStack.init(); + +Note: the HTMLElement (of type GridHTMLElement) will store a `gridstack: GridStack` value that can be retrieve later +const grid = document.querySelector('.grid-stack').gridstack; +``` + +##### initAll() + +```ts +static initAll(options, selector): GridStack[]; +``` + +Defined in: [gridstack.ts:118](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L118) + +Will initialize a list of elements (given a selector) and return an array of grids. + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `options` | [`GridStackOptions`](#gridstackoptions) | `{}` | grid options (optional) | +| `selector` | `string` | `'.grid-stack'` | elements selector to convert to grids (default to '.grid-stack' class selector) | + +###### Returns + +[`GridStack`](#gridstack-1)[] + +###### Example + +```ts +const grids = GridStack.initAll(); +grids.forEach(...) +``` + +##### isAreaEmpty() + +```ts +isAreaEmpty( + x, + y, + w, + h): boolean; +``` + +Defined in: [gridstack.ts:1066](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1066) + +Checks if specified area is empty. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `x` | `number` | the position x. | +| `y` | `number` | the position y. | +| `w` | `number` | the width of to check | +| `h` | `number` | the height of to check | + +###### Returns + +`boolean` + +##### isIgnoreChangeCB() + +```ts +isIgnoreChangeCB(): boolean; +``` + +Defined in: [gridstack.ts:978](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L978) + +true if changeCB should be ignored due to column change, sizeToContent, loading, etc... which caller can ignore for dirty flag case + +###### Returns + +`boolean` + +##### load() + +```ts +load(items, addRemove): GridStack; +``` + +Defined in: [gridstack.ts:681](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L681) + +load the widgets from a list. This will call update() on each (matching by id) or add/remove widgets that are not there. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `items` | [`GridStackWidget`](#gridstackwidget)[] | list of widgets definition to update/create | +| `addRemove` | `boolean` \| [`AddRemoveFcn`](#addremovefcn) | boolean (default true) or callback method can be passed to control if and how missing widgets can be added/removed, giving the user control of insertion. | + +###### Returns + +[`GridStack`](#gridstack-1) + +###### Example + +```ts +see http://gridstackjs.com/demo/serialization.html +``` + +##### makeSubGrid() + +```ts +makeSubGrid( + el, + ops?, + nodeToAdd?, + saveContent?): GridStack; +``` + +Defined in: [gridstack.ts:495](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L495) + +Convert an existing gridItem element into a sub-grid with the given (optional) options, else inherit them +from the parent's subGrid options. + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `el` | [`GridItemHTMLElement`](#griditemhtmlelement) | `undefined` | gridItem element to convert | +| `ops?` | [`GridStackOptions`](#gridstackoptions) | `undefined` | (optional) sub-grid options, else default to node, then parent settings, else defaults | +| `nodeToAdd?` | [`GridStackNode`](#gridstacknode-2) | `undefined` | (optional) node to add to the newly created sub grid (used when dragging over existing regular item) | +| `saveContent?` | `boolean` | `true` | if true (default) the html inside .grid-stack-content will be saved to child widget | + +###### Returns + +[`GridStack`](#gridstack-1) + +newly created grid + +##### makeWidget() + +```ts +makeWidget(els, options?): GridItemHTMLElement; +``` + +Defined in: [gridstack.ts:1083](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1083) + +If you add elements to your grid by hand (or have some framework creating DOM), you have to tell gridstack afterwards to make them widgets. +If you want gridstack to add the elements for you, use `addWidget()` instead. +Makes the given element a widget and returns it. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `els` | [`GridStackElement`](#gridstackelement) | widget or single selector to convert. | +| `options?` | [`GridStackWidget`](#gridstackwidget) | widget definition to use instead of reading attributes or using default sizing values | + +###### Returns + +[`GridItemHTMLElement`](#griditemhtmlelement) + +###### Example + +```ts +const grid = GridStack.init(); +grid.el.innerHtml = '
'; +grid.makeWidget('1'); +grid.makeWidget('2', {w:2, content: 'hello'}); +``` + +##### margin() + +```ts +margin(value): GridStack; +``` + +Defined in: [gridstack.ts:1510](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1510) + +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). + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `value` | [`numberOrString`](#numberorstring) | margin value | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### movable() + +```ts +movable(els, val): GridStack; +``` + +Defined in: [gridstack.ts:1950](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1950) + +Enables/Disables dragging by the user of specific grid element. If you want all items, and have it affect future items, use enableMove() instead. No-op for static grids. +IF you are looking to prevent an item from moving (due to being pushed around by another during collision) use locked property instead. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `els` | [`GridStackElement`](#gridstackelement) | widget or selector to modify. | +| `val` | `boolean` | if true widget will be draggable, assuming the parent grid isn't noMove or static. | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### off() + +```ts +off(name): GridStack; +``` + +Defined in: [gridstack.ts:1163](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1163) + +unsubscribe from the 'on' event GridStackEvent + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `name` | `string` | of the event (see possible values) or list of names space separated | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### offAll() + +```ts +offAll(): GridStack; +``` + +Defined in: [gridstack.ts:1183](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1183) + +remove all event handlers + +###### Returns + +[`GridStack`](#gridstack-1) + +##### on() + +###### Call Signature + +```ts +on(name, callback): GridStack; +``` + +Defined in: [gridstack.ts:1126](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1126) + +Event handler that extracts our CustomEvent data out automatically for receiving custom +notifications (see doc for supported events) + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `name` | `"dropped"` | of the event (see possible values) or list of names space separated | +| `callback` | [`GridStackDroppedHandler`](#gridstackdroppedhandler) | function called with event and optional second/third param (see README documentation for each signature). | + +###### Returns + +[`GridStack`](#gridstack-1) + +###### Example + +```ts +grid.on('added', function(e, items) { log('added ', items)} ); +or +grid.on('added removed change', function(e, items) { log(e.type, items)} ); + +Note: in some cases it is the same as calling native handler and parsing the event. +grid.el.addEventListener('added', function(event) { log('added ', event.detail)} ); +``` + +###### Call Signature + +```ts +on(name, callback): GridStack; +``` + +Defined in: [gridstack.ts:1127](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1127) + +Event handler that extracts our CustomEvent data out automatically for receiving custom +notifications (see doc for supported events) + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `name` | `"enable"` \| `"disable"` | of the event (see possible values) or list of names space separated | +| `callback` | [`GridStackEventHandler`](#gridstackeventhandler) | function called with event and optional second/third param (see README documentation for each signature). | + +###### Returns + +[`GridStack`](#gridstack-1) + +###### Example + +```ts +grid.on('added', function(e, items) { log('added ', items)} ); +or +grid.on('added removed change', function(e, items) { log(e.type, items)} ); + +Note: in some cases it is the same as calling native handler and parsing the event. +grid.el.addEventListener('added', function(event) { log('added ', event.detail)} ); +``` + +###### Call Signature + +```ts +on(name, callback): GridStack; +``` + +Defined in: [gridstack.ts:1128](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1128) + +Event handler that extracts our CustomEvent data out automatically for receiving custom +notifications (see doc for supported events) + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `name` | `"removed"` \| `"change"` \| `"added"` \| `"resizecontent"` | of the event (see possible values) or list of names space separated | +| `callback` | [`GridStackNodesHandler`](#gridstacknodeshandler) | function called with event and optional second/third param (see README documentation for each signature). | + +###### Returns + +[`GridStack`](#gridstack-1) + +###### Example + +```ts +grid.on('added', function(e, items) { log('added ', items)} ); +or +grid.on('added removed change', function(e, items) { log(e.type, items)} ); + +Note: in some cases it is the same as calling native handler and parsing the event. +grid.el.addEventListener('added', function(event) { log('added ', event.detail)} ); +``` + +###### Call Signature + +```ts +on(name, callback): GridStack; +``` + +Defined in: [gridstack.ts:1129](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1129) + +Event handler that extracts our CustomEvent data out automatically for receiving custom +notifications (see doc for supported events) + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `name` | \| `"resize"` \| `"drag"` \| `"dragstart"` \| `"resizestart"` \| `"resizestop"` \| `"dragstop"` | of the event (see possible values) or list of names space separated | +| `callback` | [`GridStackElementHandler`](#gridstackelementhandler) | function called with event and optional second/third param (see README documentation for each signature). | + +###### Returns + +[`GridStack`](#gridstack-1) + +###### Example + +```ts +grid.on('added', function(e, items) { log('added ', items)} ); +or +grid.on('added removed change', function(e, items) { log(e.type, items)} ); + +Note: in some cases it is the same as calling native handler and parsing the event. +grid.el.addEventListener('added', function(event) { log('added ', event.detail)} ); +``` + +###### Call Signature + +```ts +on(name, callback): GridStack; +``` + +Defined in: [gridstack.ts:1130](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1130) + +Event handler that extracts our CustomEvent data out automatically for receiving custom +notifications (see doc for supported events) + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `name` | `string` | of the event (see possible values) or list of names space separated | +| `callback` | [`GridStackEventHandlerCallback`](#gridstackeventhandlercallback) | function called with event and optional second/third param (see README documentation for each signature). | + +###### Returns + +[`GridStack`](#gridstack-1) + +###### Example + +```ts +grid.on('added', function(e, items) { log('added ', items)} ); +or +grid.on('added removed change', function(e, items) { log(e.type, items)} ); + +Note: in some cases it is the same as calling native handler and parsing the event. +grid.el.addEventListener('added', function(event) { log('added ', event.detail)} ); +``` + +##### onResize() + +```ts +onResize(clientWidth): GridStack; +``` + +Defined in: [gridstack.ts:1768](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1768) + +called when we are being resized - check if the one Column Mode needs to be turned on/off +and remember the prev columns we used, or get our count from parent, as well as check for cellHeight==='auto' (square) +or `sizeToContent` gridItem options. + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `clientWidth` | `number` | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### prepareDragDrop() + +```ts +prepareDragDrop(el, force?): GridStack; +``` + +Defined in: [gridstack.ts:2372](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L2372) + +prepares the element for drag&drop - this is normally called by makeWidget() unless are are delay loading + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `el` | [`GridItemHTMLElement`](#griditemhtmlelement) | `undefined` | GridItemHTMLElement of the widget | +| `force?` | `boolean` | `false` | | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### registerEngine() + +```ts +static registerEngine(engineClass): void; +``` + +Defined in: [gridstack.ts:172](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L172) + +call this method to register your engine instead of the default one. +See instead `GridStackOptions.engineClass` if you only need to +replace just one instance. + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `engineClass` | *typeof* [`GridStackEngine`](#gridstackengine-2) | + +###### Returns + +`void` + +##### removeAll() + +```ts +removeAll(removeDOM, triggerEvent): GridStack; +``` + +Defined in: [gridstack.ts:1232](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1232) + +Removes all widgets from the grid. + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `removeDOM` | `boolean` | `true` | if `false` DOM elements won't be removed from the tree (Default? `true`). | +| `triggerEvent` | `boolean` | `true` | if `false` (quiet mode) element will not be added to removed list and no 'removed' callbacks will be called (Default? true). | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### removeAsSubGrid() + +```ts +removeAsSubGrid(nodeThatRemoved?): void; +``` + +Defined in: [gridstack.ts:588](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L588) + +called when an item was converted into a nested grid to accommodate a dragged over item, but then item leaves - return back +to the original grid-item. Also called to remove empty sub-grids when last item is dragged out (since re-creating is simple) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `nodeThatRemoved?` | [`GridStackNode`](#gridstacknode-2) | + +###### Returns + +`void` + +##### removeWidget() + +```ts +removeWidget( + els, + removeDOM, + triggerEvent): GridStack; +``` + +Defined in: [gridstack.ts:1194](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1194) + +Removes widget from the grid. + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `els` | [`GridStackElement`](#gridstackelement) | `undefined` | - | +| `removeDOM` | `boolean` | `true` | if `false` DOM element won't be removed from the tree (Default? true). | +| `triggerEvent` | `boolean` | `true` | if `false` (quiet mode) element will not be added to removed list and no 'removed' callbacks will be called (Default? true). | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### resizable() + +```ts +resizable(els, val): GridStack; +``` + +Defined in: [gridstack.ts:1966](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1966) + +Enables/Disables user resizing of specific grid element. If you want all items, and have it affect future items, use enableResize() instead. No-op for static grids. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `els` | [`GridStackElement`](#gridstackelement) | widget or selector to modify | +| `val` | `boolean` | if true widget will be resizable, assuming the parent grid isn't noResize or static. | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### resizeToContent() + +```ts +resizeToContent(el): void; +``` + +Defined in: [gridstack.ts:1422](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1422) + +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. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `el` | [`GridItemHTMLElement`](#griditemhtmlelement) | grid item element | + +###### Returns + +`void` + +##### rotate() + +```ts +rotate(els, relative?): GridStack; +``` + +Defined in: [gridstack.ts:1486](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1486) + +rotate (by swapping w & h) the passed in node - called when user press 'r' during dragging + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `els` | [`GridStackElement`](#gridstackelement) | widget or selector of objects to modify | +| `relative?` | [`Position`](#position-1) | optional pixel coord relative to upper/left corner to rotate around (will keep that cell under cursor) | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### save() + +```ts +save( + saveContent, + saveGridOpt, + saveCB): + | GridStackOptions + | GridStackWidget[]; +``` + +Defined in: [gridstack.ts:619](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L619) + +saves the current layout returning a list of widgets for serialization which might include any nested grids. + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `saveContent` | `boolean` | `true` | if true (default) the latest html inside .grid-stack-content will be saved to GridStackWidget.content field, else it will be removed. | +| `saveGridOpt` | `boolean` | `false` | if true (default false), save the grid options itself, so you can call the new GridStack.addGrid() to recreate everything from scratch. GridStackOptions.children would then contain the widget list instead. | +| `saveCB` | [`SaveFcn`](#savefcn) | `GridStack.saveCB` | callback for each node -> widget, so application can insert additional data to be saved into the widget data structure. | + +###### Returns + + \| [`GridStackOptions`](#gridstackoptions) + \| [`GridStackWidget`](#gridstackwidget)[] + +list of widgets or full grid option, including .children list of widgets + +##### setAnimation() + +```ts +setAnimation(doAnimate, delay?): GridStack; +``` + +Defined in: [gridstack.ts:1251](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1251) + +Toggle the grid animation state. Toggles the `grid-stack-animate` class. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `doAnimate` | `boolean` | if true the grid will animate. | +| `delay?` | `boolean` | if true setting will be set on next event loop. | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### setStatic() + +```ts +setStatic( + val, + updateClass, + recurse): GridStack; +``` + +Defined in: [gridstack.ts:1274](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1274) + +Toggle the grid static state, which permanently removes/add Drag&Drop support, unlike disable()/enable() that just turns it off/on. +Also toggle the grid-stack-static class. + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `val` | `boolean` | `undefined` | if true the grid become static. | +| `updateClass` | `boolean` | `true` | true (default) if css class gets updated | +| `recurse` | `boolean` | `true` | true (default) if sub-grids also get updated | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### setupDragIn() + +```ts +static setupDragIn( + dragIn?, + dragInOptions?, + widgets?, + root?): void; +``` + +Defined in: [gridstack.ts:1931](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1931) + +call to setup dragging in from the outside (say toolbar), by specifying the class selection and options. +Called during GridStack.init() as options, but can also be called directly (last param are used) in case the toolbar +is dynamically create and needs to be set later. + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `dragIn?` | `string` \| `HTMLElement`[] | `undefined` | string selector (ex: '.sidebar-item') or list of dom elements | +| `dragInOptions?` | [`DDDragOpt`](#dddragopt) | `undefined` | options - see DDDragOpt. (default: {handle: '.grid-stack-item-content', appendTo: 'body'} | +| `widgets?` | [`GridStackWidget`](#gridstackwidget)[] | `undefined` | GridStackWidget def to assign to each element which defines what to create on drop | +| `root?` | `Document` \| `HTMLElement` | `document` | optional root which defaults to document (for shadow dom pass the parent HTMLDocument) | + +###### Returns + +`void` + +##### triggerEvent() + +```ts +protected triggerEvent(event, target): void; +``` + +Defined in: [gridstack.ts:2626](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L2626) + +call given event callback on our main top-most grid (if we're nested) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `event` | `Event` | +| `target` | [`GridItemHTMLElement`](#griditemhtmlelement) | + +###### Returns + +`void` + +##### update() + +```ts +update(els, opt): GridStack; +``` + +Defined in: [gridstack.ts:1330](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1330) + +Updates widget position/size and other info. Note: if you need to call this on all nodes, use load() instead which will update what changed. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `els` | [`GridStackElement`](#gridstackelement) | widget or selector of objects to modify (note: setting the same x,y for multiple items will be indeterministic and likely unwanted) | +| `opt` | [`GridStackWidget`](#gridstackwidget) | new widget options (x,y,w,h, etc..). Only those set will be updated. | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### updateOptions() + +```ts +updateOptions(o): GridStack; +``` + +Defined in: [gridstack.ts:1292](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1292) + +Updates the passed in options on the grid (similar to update(widget) for for the grid options). + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `o` | [`GridStackOptions`](#gridstackoptions) | + +###### Returns + +[`GridStack`](#gridstack-1) + +##### willItFit() + +```ts +willItFit(node): boolean; +``` + +Defined in: [gridstack.ts:1540](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L1540) + +Returns true if the height of the grid will be less than the vertical +constraint. Always returns true if grid doesn't have height constraint. + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `node` | [`GridStackWidget`](#gridstackwidget) | contains x,y,w,h,auto-position options | + +###### Returns + +`boolean` + +###### Example + +```ts +if (grid.willItFit(newWidget)) { + grid.addWidget(newWidget); +} else { + alert('Not enough free space to place the widget'); +} +``` + +#### Properties + +| Property | Modifier | Type | Default value | Description | Defined in | +| ------ | ------ | ------ | ------ | ------ | ------ | +| `addRemoveCB?` | `static` | [`AddRemoveFcn`](#addremovefcn) | `undefined` | callback method use when new items|grids needs to be created or deleted, instead of the default item:
w.content
grid:
grid content...
add = true: the returned DOM element will then be converted to a GridItemHTMLElement using makeWidget()|GridStack:init(). add = false: the item will be removed from DOM (if not already done) grid = true|false for grid vs grid-items | [gridstack.ts:184](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L184) | +| `animationDelay` | `public` | `number` | `undefined` | time to wait for animation (if enabled) to be done so content sizing can happen | [gridstack.ts:218](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L218) | +| `el` | `public` | [`GridHTMLElement`](#gridhtmlelement) | `undefined` | the HTML element tied to this grid after it's been initialized | [gridstack.ts:263](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L263) | +| `engine` | `public` | [`GridStackEngine`](#gridstackengine-2) | `undefined` | engine used to implement non DOM grid functionality | [gridstack.ts:212](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L212) | +| `Engine` | `static` | *typeof* [`GridStackEngine`](#gridstackengine-2) | `GridStackEngine` | scoping so users can call new GridStack.Engine(12) for example | [gridstack.ts:209](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L209) | +| `engineClass` | `static` | *typeof* [`GridStackEngine`](#gridstackengine-2) | `undefined` | - | [gridstack.ts:220](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L220) | +| `opts` | `public` | [`GridStackOptions`](#gridstackoptions) | `{}` | grid options - public for classes to access, but use methods to modify! | [gridstack.ts:263](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L263) | +| `parentGridNode?` | `public` | [`GridStackNode`](#gridstacknode-2) | `undefined` | point to a parent grid item if we're nested (inside a grid-item in between 2 Grids) | [gridstack.ts:215](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L215) | +| `renderCB?` | `static` | [`RenderFcn`](#renderfcn) | `undefined` | callback to create the content of widgets so the app can control how to store and restore it By default this lib will do 'el.textContent = w.content' forcing text only support for avoiding potential XSS issues. | [gridstack.ts:195](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L195) | +| `resizeObserver` | `protected` | `ResizeObserver` | `undefined` | - | [gridstack.ts:221](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L221) | +| `resizeToContentCB?` | `static` | [`ResizeToContentFcn`](#resizetocontentfcn) | `undefined` | callback to use for resizeToContent instead of the built in one | [gridstack.ts:201](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L201) | +| `resizeToContentParent` | `static` | `string` | `'.grid-stack-item-content'` | parent class for sizing content. defaults to '.grid-stack-item-content' | [gridstack.ts:203](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L203) | +| `responseLayout` | `protected` | [`ColumnOptions`](#columnoptions) | `undefined` | - | [gridstack.ts:255](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L255) | +| `saveCB?` | `static` | [`SaveFcn`](#savefcn) | `undefined` | callback during saving to application can inject extra data for each widget, on top of the grid layout properties | [gridstack.ts:189](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L189) | +| `updateCB?` | `static` | (`w`) => `void` | `undefined` | called after a widget has been updated (eg: load() into an existing list of children) so application can do extra work | [gridstack.ts:198](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L198) | +| `Utils` | `static` | *typeof* [`Utils`](#utils-1) | `Utils` | scoping so users can call GridStack.Utils.sort() for example | [gridstack.ts:206](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L206) | + +*** + + +### GridStackEngine + +Defined in: [gridstack-engine.ts:27](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L27) + +Defines the GridStack engine that does most no DOM grid manipulation. +See GridStack methods and vars for descriptions. + +NOTE: values should not be modified directly - call the main GridStack API instead + +#### Accessors + +##### float + +###### Get Signature + +```ts +get float(): boolean; +``` + +Defined in: [gridstack-engine.ts:315](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L315) + +float getter method + +###### Returns + +`boolean` + +###### Set Signature + +```ts +set float(val): void; +``` + +Defined in: [gridstack-engine.ts:306](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L306) + +enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `val` | `boolean` | + +###### Returns + +`void` + +#### Constructors + +##### Constructor + +```ts +new GridStackEngine(opts): GridStackEngine; +``` + +Defined in: [gridstack-engine.ts:54](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L54) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `opts` | [`GridStackEngineOptions`](#gridstackengineoptions) | + +###### Returns + +[`GridStackEngine`](#gridstackengine-2) + +#### Methods + +##### \_useEntireRowArea() + +```ts +protected _useEntireRowArea(node, nn): boolean; +``` + +Defined in: [gridstack-engine.ts:81](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L81) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `node` | [`GridStackNode`](#gridstacknode-2) | +| `nn` | [`GridStackPosition`](#gridstackposition) | + +###### Returns + +`boolean` + +##### addNode() + +```ts +addNode( + node, + triggerAddEvent, + after?): GridStackNode; +``` + +Defined in: [gridstack-engine.ts:545](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L545) + +call to add the given node to our list, fixing collision and re-packing + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `node` | [`GridStackNode`](#gridstacknode-2) | `undefined` | +| `triggerAddEvent` | `boolean` | `false` | +| `after?` | [`GridStackNode`](#gridstacknode-2) | `undefined` | + +###### Returns + +[`GridStackNode`](#gridstacknode-2) + +##### batchUpdate() + +```ts +batchUpdate(flag, doPack): GridStackEngine; +``` + +Defined in: [gridstack-engine.ts:63](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L63) + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `flag` | `boolean` | `true` | +| `doPack` | `boolean` | `true` | + +###### Returns + +[`GridStackEngine`](#gridstackengine-2) + +##### beginUpdate() + +```ts +beginUpdate(node): GridStackEngine; +``` + +Defined in: [gridstack-engine.ts:747](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L747) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `node` | [`GridStackNode`](#gridstacknode-2) | + +###### Returns + +[`GridStackEngine`](#gridstackengine-2) + +##### cacheLayout() + +```ts +cacheLayout( + nodes, + column, + clear): GridStackEngine; +``` + +Defined in: [gridstack-engine.ts:937](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L937) + +call to cache the given layout internally to the given location so we can restore back when column changes size + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `nodes` | [`GridStackNode`](#gridstacknode-2)[] | `undefined` | list of nodes | +| `column` | `number` | `undefined` | corresponding column index to save it under | +| `clear` | `boolean` | `false` | if true, will force other caches to be removed (default false) | + +###### Returns + +[`GridStackEngine`](#gridstackengine-2) + +##### cacheOneLayout() + +```ts +cacheOneLayout(n, column): GridStackEngine; +``` + +Defined in: [gridstack-engine.ts:957](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L957) + +call to cache the given node layout internally to the given location so we can restore back when column changes size + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `n` | [`GridStackNode`](#gridstacknode-2) | - | +| `column` | `number` | corresponding column index to save it under | + +###### Returns + +[`GridStackEngine`](#gridstackengine-2) + +##### cacheRects() + +```ts +cacheRects( + w, + h, + top, + right, + bottom, + left): GridStackEngine; +``` + +Defined in: [gridstack-engine.ts:225](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L225) + +called to cache the nodes pixel rectangles used for collision detection during drag + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `w` | `number` | +| `h` | `number` | +| `top` | `number` | +| `right` | `number` | +| `bottom` | `number` | +| `left` | `number` | + +###### Returns + +[`GridStackEngine`](#gridstackengine-2) + +##### changedPosConstrain() + +```ts +changedPosConstrain(node, p): boolean; +``` + +Defined in: [gridstack-engine.ts:669](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L669) + +true if x,y or w,h are different after clamping to min/max + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `node` | [`GridStackNode`](#gridstacknode-2) | +| `p` | [`GridStackPosition`](#gridstackposition) | + +###### Returns + +`boolean` + +##### cleanupNode() + +```ts +cleanupNode(node): GridStackEngine; +``` + +Defined in: [gridstack-engine.ts:988](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L988) + +called to remove all internal values but the _id + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `node` | [`GridStackNode`](#gridstacknode-2) | + +###### Returns + +[`GridStackEngine`](#gridstackengine-2) + +##### collide() + +```ts +collide( + skip, + area, + skip2?): GridStackNode; +``` + +Defined in: [gridstack-engine.ts:146](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L146) + +return the nodes that intercept the given node. Optionally a different area can be used, as well as a second node to skip + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `skip` | [`GridStackNode`](#gridstacknode-2) | `undefined` | +| `area` | [`GridStackNode`](#gridstacknode-2) | `skip` | +| `skip2?` | [`GridStackNode`](#gridstacknode-2) | `undefined` | + +###### Returns + +[`GridStackNode`](#gridstacknode-2) + +##### collideAll() + +```ts +collideAll( + skip, + area, + skip2?): GridStackNode[]; +``` + +Defined in: [gridstack-engine.ts:151](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L151) + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `skip` | [`GridStackNode`](#gridstacknode-2) | `undefined` | +| `area` | [`GridStackNode`](#gridstacknode-2) | `skip` | +| `skip2?` | [`GridStackNode`](#gridstacknode-2) | `undefined` | + +###### Returns + +[`GridStackNode`](#gridstacknode-2)[] + +##### compact() + +```ts +compact(layout, doSort): GridStackEngine; +``` + +Defined in: [gridstack-engine.ts:283](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L283) + +re-layout grid items to reclaim any empty space - optionally keeping the sort order exactly the same ('list' mode) vs truly finding an empty spaces + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `layout` | [`CompactOptions`](#compactoptions) | `'compact'` | +| `doSort` | `boolean` | `true` | + +###### Returns + +[`GridStackEngine`](#gridstackengine-2) + +##### directionCollideCoverage() + +```ts +protected directionCollideCoverage( + node, + o, + collides): GridStackNode; +``` + +Defined in: [gridstack-engine.ts:158](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L158) + +does a pixel coverage collision based on where we started, returning the node that has the most coverage that is >50% mid line + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `node` | [`GridStackNode`](#gridstacknode-2) | +| `o` | [`GridStackMoveOpts`](#gridstackmoveopts) | +| `collides` | [`GridStackNode`](#gridstacknode-2)[] | + +###### Returns + +[`GridStackNode`](#gridstacknode-2) + +##### endUpdate() + +```ts +endUpdate(): GridStackEngine; +``` + +Defined in: [gridstack-engine.ts:756](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L756) + +###### Returns + +[`GridStackEngine`](#gridstackengine-2) + +##### findCacheLayout() + +```ts +protected findCacheLayout(n, column): number; +``` + +Defined in: [gridstack-engine.ts:971](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L971) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `n` | [`GridStackNode`](#gridstacknode-2) | +| `column` | `number` | + +###### Returns + +`number` + +##### findEmptyPosition() + +```ts +findEmptyPosition( + node, + nodeList, + column, + after?): boolean; +``` + +Defined in: [gridstack-engine.ts:523](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L523) + +find the first available empty spot for the given node width/height, updating the x,y attributes. return true if found. +optionally you can pass your own existing node list and column count, otherwise defaults to that engine data. +Optionally pass a widget to start search AFTER, meaning the order will remain the same but possibly have empty slots we skipped + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `node` | [`GridStackNode`](#gridstacknode-2) | +| `nodeList` | [`GridStackNode`](#gridstacknode-2)[] | +| `column` | `number` | +| `after?` | [`GridStackNode`](#gridstacknode-2) | + +###### Returns + +`boolean` + +##### getDirtyNodes() + +```ts +getDirtyNodes(verify?): GridStackNode[]; +``` + +Defined in: [gridstack-engine.ts:470](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L470) + +returns a list of modified nodes from their original values + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `verify?` | `boolean` | + +###### Returns + +[`GridStackNode`](#gridstacknode-2)[] + +##### getRow() + +```ts +getRow(): number; +``` + +Defined in: [gridstack-engine.ts:743](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L743) + +###### Returns + +`number` + +##### isAreaEmpty() + +```ts +isAreaEmpty( + x, + y, + w, + h): boolean; +``` + +Defined in: [gridstack-engine.ts:277](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L277) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `x` | `number` | +| `y` | `number` | +| `w` | `number` | +| `h` | `number` | + +###### Returns + +`boolean` + +##### moveNode() + +```ts +moveNode(node, o): boolean; +``` + +Defined in: [gridstack-engine.ts:683](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L683) + +return true if the passed in node was actually moved (checks for no-op and locked) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `node` | [`GridStackNode`](#gridstacknode-2) | +| `o` | [`GridStackMoveOpts`](#gridstackmoveopts) | + +###### Returns + +`boolean` + +##### moveNodeCheck() + +```ts +moveNodeCheck(node, o): boolean; +``` + +Defined in: [gridstack-engine.ts:597](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L597) + +checks if item can be moved (layout constrain) vs moveNode(), returning true if was able to move. +In more complicated cases (maxRow) it will attempt at moving the item and fixing +others in a clone first, then apply those changes if still within specs. + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `node` | [`GridStackNode`](#gridstacknode-2) | +| `o` | [`GridStackMoveOpts`](#gridstackmoveopts) | + +###### Returns + +`boolean` + +##### nodeBoundFix() + +```ts +nodeBoundFix(node, resizing?): GridStackEngine; +``` + +Defined in: [gridstack-engine.ts:407](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L407) + +part2 of preparing a node to fit inside our grid - checks for x,y,w from grid dimensions + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `node` | [`GridStackNode`](#gridstacknode-2) | +| `resizing?` | `boolean` | + +###### Returns + +[`GridStackEngine`](#gridstackengine-2) + +##### prepareNode() + +```ts +prepareNode(node, resizing?): GridStackNode; +``` + +Defined in: [gridstack-engine.ts:366](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L366) + +given a random node, makes sure it's coordinates/values are valid in the current grid + +###### Parameters + +| Parameter | Type | Description | +| ------ | ------ | ------ | +| `node` | [`GridStackNode`](#gridstacknode-2) | to adjust | +| `resizing?` | `boolean` | if out of bound, resize down or move into the grid to fit ? | + +###### Returns + +[`GridStackNode`](#gridstacknode-2) + +##### removeAll() + +```ts +removeAll(removeDOM, triggerEvent): GridStackEngine; +``` + +Defined in: [gridstack-engine.ts:584](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L584) + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `removeDOM` | `boolean` | `true` | +| `triggerEvent` | `boolean` | `true` | + +###### Returns + +[`GridStackEngine`](#gridstackengine-2) + +##### removeNode() + +```ts +removeNode( + node, + removeDOM, + triggerEvent): GridStackEngine; +``` + +Defined in: [gridstack-engine.ts:568](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L568) + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `node` | [`GridStackNode`](#gridstacknode-2) | `undefined` | +| `removeDOM` | `boolean` | `true` | +| `triggerEvent` | `boolean` | `false` | + +###### Returns + +[`GridStackEngine`](#gridstackengine-2) + +##### removeNodeFromLayoutCache() + +```ts +removeNodeFromLayoutCache(n): void; +``` + +Defined in: [gridstack-engine.ts:975](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L975) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `n` | [`GridStackNode`](#gridstacknode-2) | + +###### Returns + +`void` + +##### save() + +```ts +save(saveElement, saveCB?): GridStackNode[]; +``` + +Defined in: [gridstack-engine.ts:767](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L767) + +saves a copy of the largest column layout (eg 12 even when rendering oneColumnMode) so we don't loose orig layout, +returning a list of widgets for serialization + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `saveElement` | `boolean` | `true` | +| `saveCB?` | [`SaveFcn`](#savefcn) | `undefined` | + +###### Returns + +[`GridStackNode`](#gridstacknode-2)[] + +##### sortNodes() + +```ts +sortNodes(dir): GridStackEngine; +``` + +Defined in: [gridstack-engine.ts:318](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L318) + +sort the nodes array from first to last, or reverse. Called during collision/placement to force an order + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `dir` | `-1` \| `1` | `1` | + +###### Returns + +[`GridStackEngine`](#gridstackengine-2) + +##### swap() + +```ts +swap(a, b): boolean; +``` + +Defined in: [gridstack-engine.ts:239](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L239) + +called to possibly swap between 2 nodes (same size or column, not locked, touching), returning true if successful + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `a` | [`GridStackNode`](#gridstacknode-2) | +| `b` | [`GridStackNode`](#gridstacknode-2) | + +###### Returns + +`boolean` + +##### willItFit() + +```ts +willItFit(node): boolean; +``` + +Defined in: [gridstack-engine.ts:648](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L648) + +return true if can fit in grid height constrain only (always true if no maxRow) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `node` | [`GridStackNode`](#gridstacknode-2) | + +###### Returns + +`boolean` + +#### Properties + +| Property | Modifier | Type | Default value | Description | Defined in | +| ------ | ------ | ------ | ------ | ------ | ------ | +| `addedNodes` | `public` | [`GridStackNode`](#gridstacknode-2)[] | `[]` | - | [gridstack-engine.ts:31](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L31) | +| `batchMode` | `public` | `boolean` | `undefined` | - | [gridstack-engine.ts:33](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L33) | +| `column` | `public` | `number` | `undefined` | - | [gridstack-engine.ts:28](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L28) | +| `defaultColumn` | `public` | `number` | `12` | - | [gridstack-engine.ts:34](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L34) | +| `maxRow` | `public` | `number` | `undefined` | - | [gridstack-engine.ts:29](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L29) | +| `nodes` | `public` | [`GridStackNode`](#gridstacknode-2)[] | `undefined` | - | [gridstack-engine.ts:30](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L30) | +| `removedNodes` | `public` | [`GridStackNode`](#gridstacknode-2)[] | `[]` | - | [gridstack-engine.ts:32](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L32) | +| `skipCacheUpdate?` | `public` | `boolean` | `undefined` | true when grid.load() already cached the layout and can skip out of bound caching info | [gridstack-engine.ts:48](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack-engine.ts#L48) | + +*** + + +### Utils + +Defined in: [utils.ts:61](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L61) + +Utility methods + +#### Constructors + +##### Constructor + +```ts +new Utils(): Utils; +``` + +###### Returns + +[`Utils`](#utils-1) + +#### Methods + +##### addElStyles() + +```ts +static addElStyles(el, styles): void; +``` + +Defined in: [utils.ts:469](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L469) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `el` | `HTMLElement` | +| `styles` | \{ \[`prop`: `string`\]: `string` \| `string`[]; \} | + +###### Returns + +`void` + +##### appendTo() + +```ts +static appendTo(el, parent): void; +``` + +Defined in: [utils.ts:451](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L451) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `el` | `HTMLElement` | +| `parent` | `string` \| `HTMLElement` | + +###### Returns + +`void` + +##### area() + +```ts +static area(a): number; +``` + +Defined in: [utils.ts:154](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L154) + +returns the area + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `a` | [`GridStackPosition`](#gridstackposition) | + +###### Returns + +`number` + +##### areaIntercept() + +```ts +static areaIntercept(a, b): number; +``` + +Defined in: [utils.ts:143](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L143) + +returns the area a and b overlap + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `a` | [`GridStackPosition`](#gridstackposition) | +| `b` | [`GridStackPosition`](#gridstackposition) | + +###### Returns + +`number` + +##### canBeRotated() + +```ts +static canBeRotated(n): boolean; +``` + +Defined in: [utils.ts:572](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L572) + +true if the item can be rotated (checking for prop, not space available) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `n` | [`GridStackNode`](#gridstacknode-2) | + +###### Returns + +`boolean` + +##### clone() + +```ts +static clone(obj): T; +``` + +Defined in: [utils.ts:414](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L414) + +single level clone, returning a new object with same top fields. This will share sub objects and arrays + +###### Type Parameters + +| Type Parameter | +| ------ | +| `T` | + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `obj` | `T` | + +###### Returns + +`T` + +##### cloneDeep() + +```ts +static cloneDeep(obj): T; +``` + +Defined in: [utils.ts:430](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L430) + +Recursive clone version that returns a full copy, checking for nested objects and arrays ONLY. +Note: this will use as-is any key starting with double __ (and not copy inside) some lib have circular dependencies. + +###### Type Parameters + +| Type Parameter | +| ------ | +| `T` | + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `obj` | `T` | + +###### Returns + +`T` + +##### cloneNode() + +```ts +static cloneNode(el): HTMLElement; +``` + +Defined in: [utils.ts:445](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L445) + +deep clone the given HTML node, removing teh unique id field + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `el` | `HTMLElement` | + +###### Returns + +`HTMLElement` + +##### copyPos() + +```ts +static copyPos( + a, + b, + doMinMax): GridStackWidget; +``` + +Defined in: [utils.ts:244](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L244) + +copies over b size & position (GridStackPosition), and optionally min/max as well + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `a` | [`GridStackWidget`](#gridstackwidget) | `undefined` | +| `b` | [`GridStackWidget`](#gridstackwidget) | `undefined` | +| `doMinMax` | `boolean` | `false` | + +###### Returns + +[`GridStackWidget`](#gridstackwidget) + +##### createDiv() + +```ts +static createDiv(classes, parent?): HTMLElement; +``` + +Defined in: [utils.ts:118](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L118) + +create a div with the given classes + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `classes` | `string`[] | +| `parent?` | `HTMLElement` | + +###### Returns + +`HTMLElement` + +##### defaults() + +```ts +static defaults(target, ...sources): object; +``` + +Defined in: [utils.ts:214](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L214) + +copies unset fields in target to use the given default sources values + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `target` | `any` | +| ...`sources` | `any`[] | + +###### Returns + +`object` + +##### find() + +```ts +static find(nodes, id): GridStackNode; +``` + +Defined in: [utils.ts:173](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L173) + +find an item by id + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `nodes` | [`GridStackNode`](#gridstacknode-2)[] | +| `id` | `string` | + +###### Returns + +[`GridStackNode`](#gridstacknode-2) + +##### getElement() + +```ts +static getElement(els, root): HTMLElement; +``` + +Defined in: [utils.ts:87](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L87) + +convert a potential selector into actual single element. optional root which defaults to document (for shadow dom) + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `els` | [`GridStackElement`](#gridstackelement) | `undefined` | +| `root` | `Document` \| `HTMLElement` | `document` | + +###### Returns + +`HTMLElement` + +##### getElements() + +```ts +static getElements(els, root): HTMLElement[]; +``` + +Defined in: [utils.ts:64](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L64) + +convert a potential selector into actual list of html elements. optional root which defaults to document (for shadow dom) + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `els` | [`GridStackElement`](#gridstackelement) | `undefined` | +| `root` | `Document` \| `HTMLElement` | `document` | + +###### Returns + +`HTMLElement`[] + +##### getValuesFromTransformedElement() + +```ts +static getValuesFromTransformedElement(parent): DragTransform; +``` + +Defined in: [utils.ts:529](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L529) + +defines an element that is used to get the offset and scale from grid transforms +returns the scale and offsets from said element + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `parent` | `HTMLElement` | + +###### Returns + +[`DragTransform`](#dragtransform) + +##### initEvent() + +```ts +static initEvent(e, info): T; +``` + +Defined in: [utils.ts:486](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L486) + +###### Type Parameters + +| Type Parameter | +| ------ | +| `T` | + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `e` | `MouseEvent` \| `DragEvent` | +| `info` | \{ `target?`: `EventTarget`; `type`: `string`; \} | +| `info.target?` | `EventTarget` | +| `info.type` | `string` | + +###### Returns + +`T` + +##### isIntercepted() + +```ts +static isIntercepted(a, b): boolean; +``` + +Defined in: [utils.ts:133](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L133) + +returns true if a and b overlap + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `a` | [`GridStackPosition`](#gridstackposition) | +| `b` | [`GridStackPosition`](#gridstackposition) | + +###### Returns + +`boolean` + +##### isTouching() + +```ts +static isTouching(a, b): boolean; +``` + +Defined in: [utils.ts:138](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L138) + +returns true if a and b touch edges or corners + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `a` | [`GridStackPosition`](#gridstackposition) | +| `b` | [`GridStackPosition`](#gridstackposition) | + +###### Returns + +`boolean` + +##### lazyLoad() + +```ts +static lazyLoad(n): boolean; +``` + +Defined in: [utils.ts:113](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L113) + +true if widget (or grid) makes this item lazyLoad + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `n` | [`GridStackNode`](#gridstacknode-2) | + +###### Returns + +`boolean` + +##### parseHeight() + +```ts +static parseHeight(val): HeightData; +``` + +Defined in: [utils.ts:193](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L193) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `val` | [`numberOrString`](#numberorstring) | + +###### Returns + +[`HeightData`](#heightdata) + +##### removeInternalAndSame() + +```ts +static removeInternalAndSame(a, b): void; +``` + +Defined in: [utils.ts:273](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L273) + +removes field from the first object if same as the second objects (like diffing) and internal '_' for saving + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `a` | `unknown` | +| `b` | `unknown` | + +###### Returns + +`void` + +##### removeInternalForSave() + +```ts +static removeInternalForSave(n, removeEl): void; +``` + +Defined in: [utils.ts:288](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L288) + +removes internal fields '_' and default values for saving + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `n` | [`GridStackNode`](#gridstacknode-2) | `undefined` | +| `removeEl` | `boolean` | `true` | + +###### Returns + +`void` + +##### removePositioningStyles() + +```ts +static removePositioningStyles(el): void; +``` + +Defined in: [utils.ts:321](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L321) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `el` | `HTMLElement` | + +###### Returns + +`void` + +##### same() + +```ts +static same(a, b): boolean; +``` + +Defined in: [utils.ts:232](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L232) + +given 2 objects return true if they have the same values. Checks for Object {} having same fields and values (just 1 level down) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `a` | `unknown` | +| `b` | `unknown` | + +###### Returns + +`boolean` + +##### samePos() + +```ts +static samePos(a, b): boolean; +``` + +Defined in: [utils.ts:259](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L259) + +true if a and b has same size & position + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `a` | [`GridStackPosition`](#gridstackposition) | +| `b` | [`GridStackPosition`](#gridstackposition) | + +###### Returns + +`boolean` + +##### sanitizeMinMax() + +```ts +static sanitizeMinMax(node): void; +``` + +Defined in: [utils.ts:264](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L264) + +given a node, makes sure it's min/max are valid + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `node` | [`GridStackNode`](#gridstacknode-2) | + +###### Returns + +`void` + +##### shouldSizeToContent() + +```ts +static shouldSizeToContent(n, strict): boolean; +``` + +Defined in: [utils.ts:126](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L126) + +true if we should resize to content. strict=true when only 'sizeToContent:true' and not a number which lets user adjust + +###### Parameters + +| Parameter | Type | Default value | +| ------ | ------ | ------ | +| `n` | [`GridStackNode`](#gridstacknode-2) | `undefined` | +| `strict` | `boolean` | `false` | + +###### Returns + +`boolean` + +##### simulateMouseEvent() + +```ts +static simulateMouseEvent( + e, + simulatedType, + target?): void; +``` + +Defined in: [utils.ts:502](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L502) + +copies the MouseEvent (or convert Touch) properties and sends it as another event to the given target + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `e` | `MouseEvent` \| `Touch` | +| `simulatedType` | `string` | +| `target?` | `EventTarget` | + +###### Returns + +`void` + +##### sort() + +```ts +static sort(nodes, dir): GridStackNode[]; +``` + +Defined in: [utils.ts:163](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L163) + +Sorts array of nodes + +###### Parameters + +| Parameter | Type | Default value | Description | +| ------ | ------ | ------ | ------ | +| `nodes` | [`GridStackNode`](#gridstacknode-2)[] | `undefined` | array to sort | +| `dir` | `-1` \| `1` | `1` | 1 for ascending, -1 for descending (optional) | + +###### Returns + +[`GridStackNode`](#gridstacknode-2)[] + +##### swap() + +```ts +static swap( + o, + a, + b): void; +``` + +Defined in: [utils.ts:553](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L553) + +swap the given object 2 field values + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `o` | `unknown` | +| `a` | `string` | +| `b` | `string` | + +###### Returns + +`void` + +##### throttle() + +```ts +static throttle(func, delay): () => void; +``` + +Defined in: [utils.ts:311](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L311) + +delay calling the given function for given delay, preventing new calls from happening while waiting + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `func` | () => `void` | +| `delay` | `number` | + +###### Returns + +```ts +(): void; +``` + +###### Returns + +`void` + +##### toBool() + +```ts +static toBool(v): boolean; +``` + +Defined in: [utils.ts:178](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L178) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `v` | `unknown` | + +###### Returns + +`boolean` + +##### toNumber() + +```ts +static toNumber(value): number; +``` + +Defined in: [utils.ts:189](https://github.com/adumesny/gridstack.js/blob/master/src/utils.ts#L189) + +###### Parameters + +| Parameter | Type | +| ------ | ------ | +| `value` | `string` | + +###### Returns + +`number` + +## Interfaces + + +### GridStackOptions + +Defined in: [types.ts:110](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L110) + +Defines the options for a Grid + +#### Properties + +| Property | Type | Description | Defined in | +| ------ | ------ | ------ | ------ | +| `acceptWidgets?` | `string` \| `boolean` \| (`element`) => `boolean` | accept widgets dragged from other grids or from outside (default: `false`). Can be: `true` (uses `'.grid-stack-item'` class filter) or `false`, string for explicit class name, function returning a boolean. See [example](http://gridstack.github.io/gridstack.js/demo/two.html) | [types.ts:117](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L117) | +| `alwaysShowResizeHandle?` | `boolean` \| `"mobile"` | possible values (default: `mobile`) - does not apply to non-resizable widgets `false` the resizing handles are only shown while hovering over a widget `true` the resizing handles are always shown 'mobile' if running on a mobile device, default to `true` (since there is no hovering per say), else `false`. See [example](http://gridstack.github.io/gridstack.js/demo/mobile.html) | [types.ts:124](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L124) | +| `animate?` | `boolean` | turns animation on (default?: true) | [types.ts:127](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L127) | +| `auto?` | `boolean` | if false gridstack will not initialize existing items (default?: true) | [types.ts:130](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L130) | +| `cellHeight?` | [`numberOrString`](#numberorstring) | one cell height (default?: 'auto'). Can be: an integer (px) a string (ex: '100px', '10em', '10rem'). Note: % doesn't work right - see demo/cell-height.html 0, in which case the library will not generate styles for rows. Everything must be defined in your own CSS files. 'auto' - height will be calculated for square cells (width / column) and updated live as you resize the window - also see `cellHeightThrottle` 'initial' - similar to 'auto' (start at square cells) but stay that size during window resizing. | [types.ts:140](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L140) | +| `cellHeightThrottle?` | `number` | throttle time delay (in ms) used when cellHeight='auto' to improve performance vs usability (default?: 100). A value of 0 will make it instant at a cost of re-creating the CSS file at ever window resize event! | [types.ts:145](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L145) | +| `cellHeightUnit?` | `string` | (internal) unit for cellHeight (default? 'px') which is set when a string cellHeight with a unit is passed (ex: '10rem') | [types.ts:148](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L148) | +| `children?` | [`GridStackWidget`](#gridstackwidget)[] | list of children item to create when calling load() or addGrid() | [types.ts:151](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L151) | +| `class?` | `string` | additional class on top of '.grid-stack' (which is required for our CSS) to differentiate this instance. Note: only used by addGrid(), else your element should have the needed class | [types.ts:164](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L164) | +| `column?` | `number` \| `"auto"` | number of columns (default?: 12). Note: IF you change this, CSS also have to change. See https://github.com/gridstack/gridstack.js#change-grid-columns. Note: for nested grids, it is recommended to use 'auto' which will always match the container grid-item current width (in column) to keep inside and outside items always the same. flag is NOT supported for regular non-nested grids. | [types.ts:157](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L157) | +| `columnOpts?` | [`Responsive`](#responsive) | responsive column layout for width:column behavior | [types.ts:160](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L160) | +| `disableDrag?` | `boolean` | disallows dragging of widgets (default?: false) | [types.ts:167](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L167) | +| `disableResize?` | `boolean` | disallows resizing of widgets (default?: false). | [types.ts:170](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L170) | +| `draggable?` | [`DDDragOpt`](#dddragopt) | allows to override UI draggable options. (default?: { handle?: '.grid-stack-item-content', appendTo?: 'body' }) | [types.ts:173](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L173) | +| `engineClass?` | *typeof* [`GridStackEngine`](#gridstackengine-2) | the type of engine to create (so you can subclass) default to GridStackEngine | [types.ts:179](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L179) | +| `float?` | `boolean` | enable floating widgets (default?: false) See example (http://gridstack.github.io/gridstack.js/demo/float.html) | [types.ts:182](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L182) | +| `handle?` | `string` | draggable handle selector (default?: '.grid-stack-item-content') | [types.ts:185](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L185) | +| `handleClass?` | `string` | draggable handle class (e.g. 'grid-stack-item-content'). If set 'handle' is ignored (default?: null) | [types.ts:188](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L188) | +| `itemClass?` | `string` | additional widget class (default?: 'grid-stack-item') | [types.ts:191](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L191) | +| `layout?` | [`ColumnOptions`](#columnoptions) | re-layout mode when we're a subgrid and we are being resized. default to 'list' | [types.ts:194](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L194) | +| `lazyLoad?` | `boolean` | true when widgets are only created when they scroll into view (visible) | [types.ts:197](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L197) | +| `margin?` | [`numberOrString`](#numberorstring) | gap between grid item and content (default?: 10). This will set all 4 sides and support the CSS formats below an integer (px) a string with possible units (ex: '2em', '20px', '2rem') string with space separated values (ex: '5px 10px 0 20px' for all 4 sides, or '5em 10em' for top/bottom and left/right pairs like CSS). Note: all sides must have same units (last one wins, default px) | [types.ts:206](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L206) | +| `marginBottom?` | [`numberOrString`](#numberorstring) | - | [types.ts:211](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L211) | +| `marginLeft?` | [`numberOrString`](#numberorstring) | - | [types.ts:212](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L212) | +| `marginRight?` | [`numberOrString`](#numberorstring) | - | [types.ts:210](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L210) | +| `marginTop?` | [`numberOrString`](#numberorstring) | OLD way to optionally set each side - use margin: '5px 10px 0 20px' instead. Used internally to store each side. | [types.ts:209](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L209) | +| `marginUnit?` | `string` | (internal) unit for margin (default? 'px') set when `margin` is set as string with unit (ex: 2rem') | [types.ts:215](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L215) | +| `maxRow?` | `number` | maximum rows amount. Default? is 0 which means no maximum rows | [types.ts:218](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L218) | +| `minRow?` | `number` | minimum rows amount which is handy to prevent grid from collapsing when empty. Default is `0`. When no set the `min-height` CSS attribute on the grid div (in pixels) can be used, which will round to the closest row. | [types.ts:223](https://github.com/adumesny/gridstack.js/blob/master/src/types.ts#L223) | +| `nonce?` | `string` | If you are using a nonce-based Content Security Policy, pass your nonce here and GridStack will add it to the