Static
addStatic
appendStatic
areaCalculate the total area of a grid position.
position with width and height
the total area (width * height)
Static
areaCalculate the overlapping area between two grid positions.
first position
second position
the area of overlap (0 if no overlap)
Static
cantrue if the item can be rotated (checking for prop, not space available)
Static
cloneStatic
cloneStatic
clonedeep clone the given HTML node, removing teh unique id field
Static
copyCopy 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)
Static
createCreate a div element with the specified CSS classes.
array of CSS class names to add
Optional
parent: HTMLElementoptional parent element to append the div to
the created div element
Static
defaultsCopy 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
Static
findFind 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
Static
getConvert 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
Static
getConvert 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
Static
getdefines an element that is used to get the offset and scale from grid transforms returns the scale and offsets from said element
Static
initStatic
isCheck 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
Static
isCheck if two grid positions are touching (edges or corners).
first position
second position
true if the positions are touching
Static
lazyCheck 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
Static
parseParse 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
Static
removeremoves field from the first object if same as the second objects (like diffing) and internal '_' for saving
Static
removeremoves internal fields '_' and default values for saving
Static
removeStatic
sameCompare 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
Static
sametrue if a and b has same size & position
Static
sanitizeStatic
shouldCheck 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
Static
simulatecopies the MouseEvent (or convert Touch) properties and sends it as another event to the given target
Optional
target: EventTargetStatic
sortSort 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)
Static
swapswap the given object 2 field values
Static
throttledelay calling the given function for given delay, preventing new calls from happening while waiting
Static
toStatic
to
Collection of utility methods used throughout GridStack. These are general-purpose helper functions for DOM manipulation, positioning calculations, object operations, and more.