StaticaddStaticappendStaticareaCalculate the total area of a grid position.
position with width and height
the total area (width * height)
StaticareaCalculate the overlapping area between two grid positions.
first position
second position
the area of overlap (0 if no overlap)
Staticcantrue if the item can be rotated (checking for prop, not space available)
StaticcloneStaticcloneStaticclonedeep clone the given HTML node, removing teh unique id field
StaticcopyCopy position and size properties from one widget to another. Copies x, y, w, h and optionally min/max constraints.
target widget to copy to
source widget to copy from
if true, also copy min/max width/height constraints
the target widget (a)
StaticcreateCreate a div element with the specified CSS classes.
array of CSS class names to add
Optionalparent: HTMLElementoptional parent element to append the div to
the created div element
StaticdefaultsCopy unset fields from source objects to target object (shallow merge with defaults). Similar to Object.assign but only sets undefined/null fields.
the object to copy defaults into
one or more source objects to copy defaults from
the modified target object
StaticfindFind a grid node by its ID.
array of nodes to search
the ID to search for
the node with matching ID, or undefined if not found
StaticgetConvert a potential selector into a single HTML element. Similar to getElements() but returns only the first match.
selector string or HTMLElement
optional root element to search within (defaults to document)
the first HTML element matching the selector, or null if not found
StaticgetConvert a potential selector into an actual list of HTML elements. Supports CSS selectors, element references, and special ID handling.
selector string, HTMLElement, or array of elements
optional root element to search within (defaults to document, useful for shadow DOM)
array of HTML elements matching the selector
Staticgetdefines an element that is used to get the offset and scale from grid transforms returns the scale and offsets from said element
StaticinitStaticisCheck if two grid positions overlap/intersect.
first position with x, y, w, h properties
second position with x, y, w, h properties
true if the positions overlap
StaticisCheck if two grid positions are touching (edges or corners).
first position
second position
true if the positions are touching
StaticlazyCheck if a widget should be lazy loaded based on node or grid settings.
the grid node to check
true if the item should be lazy loaded
StaticparseParse a height value with units into numeric value and unit string. Supports px, em, rem, vh, vw, %, cm, mm units.
height value as number or string with units
object with h (height) and unit properties
Staticremoveremoves field from the first object if same as the second objects (like diffing) and internal '_' for saving
Staticremoveremoves internal fields '_' and default values for saving
StaticremoveStaticsameCompare two objects for equality (shallow comparison). Checks if objects have the same fields and values at one level deep.
first object to compare
second object to compare
true if objects have the same values
Staticsametrue if a and b has same size & position
StaticsanitizeStaticshouldCheck if a widget should resize to fit its content.
the grid node to check (can be undefined)
if true, only returns true for explicit sizeToContent:true (not numbers)
true if the widget should resize to content
Staticsimulatecopies the MouseEvent (or convert Touch) properties and sends it as another event to the given target
Optionaltarget: EventTargetStaticsortSort an array of grid nodes by position (y first, then x).
array of nodes to sort
sort direction: 1 for ascending (top-left first), -1 for descending
the sorted array (modifies original)
Staticswapswap the given object 2 field values
Staticthrottledelay calling the given function for given delay, preventing new calls from happening while waiting
StatictoStaticto
Collection of utility methods used throughout GridStack. These are general-purpose helper functions for DOM manipulation, positioning calculations, object operations, and more.