Enable/disable floating widgets (default: false
).
When floating is enabled, widgets can move up to fill empty spaces.
See example
true to enable floating, false to disable
Protected
_Add the given node to the grid, handling collision detection and re-packing. This is the main method for adding new widgets to the engine.
the node to add to the grid
if true, adds node to addedNodes list for event triggering
Optional
after: GridStackNodeoptional node to place this node after (for ordering)
the added node (or existing node if duplicate)
Enable/disable batch mode for multiple operations to optimize performance. When enabled, layout updates are deferred until batch mode is disabled.
true to enable batch mode, false to disable and apply changes
if true (default), pack/compact nodes when disabling batch mode
the engine instance for chaining
call to cache the given layout internally to the given location so we can restore back when column changes size
list of nodes
corresponding column index to save it under
if true, will force other caches to be removed (default false)
call to cache the given node layout internally to the given location so we can restore back when column changes size
corresponding column index to save it under
true if x,y or w,h are different after clamping to min/max
called to remove all internal values but the _id
Return the first node that intercepts/collides with the given node or area. Used for collision detection during drag and drop operations.
the node to skip in collision detection (usually the node being moved)
the area to check for collisions (defaults to skip node's area)
Optional
skip2: GridStackNodeoptional second node to skip in collision detection
the first colliding node, or undefined if no collision
Return all nodes that intercept/collide with the given node or area. Similar to collide() but returns all colliding nodes instead of just the first.
the node to skip in collision detection
the area to check for collisions (defaults to skip node's area)
Optional
skip2: GridStackNodeoptional second node to skip in collision detection
array of all colliding nodes
Re-layout grid items to reclaim any empty space. This optimizes the grid layout by moving items to fill gaps.
layout algorithm to use:
if true (default), sort nodes by position before compacting
the engine instance for chaining
Protected
directiondoes a pixel coverage collision based on where we started, returning the node that has the most coverage that is >50% mid line
Protected
findFind the first available empty spot for the given node dimensions. Updates the node's x,y attributes with the found position.
the node to find a position for (w,h must be set)
optional list of nodes to check against (defaults to engine nodes)
optional column count (defaults to engine column count)
Optional
after: GridStackNodeoptional node to start search after (maintains order)
true if an empty position was found and node was updated
Returns a list of nodes that have been modified from their original values. This is used to track which nodes need DOM updates.
Optional
verify: booleanif true, performs additional verification by comparing current vs original positions
array of nodes that have been modified
Check if the specified rectangular area is empty (no nodes occupy any part of it).
the x coordinate (column) of the area to check
the y coordinate (row) of the area to check
the width in columns of the area to check
the height in rows of the area to check
true if the area is completely empty, false if any node overlaps
return true if the passed in node was actually moved (checks for no-op and locked)
Check if a node can be moved to a new position, considering layout constraints. This is a safer version of moveNode() that validates the move first.
For complex cases (like maxRow constraints), it simulates the move in a clone first, then applies the changes only if they meet all specifications.
the node to move
move options including target position
true if the node was successfully moved
Part 2 of preparing a node to fit inside the grid - validates and fixes coordinates and dimensions. This ensures the node fits within grid boundaries and respects min/max constraints.
the node to validate and fix
Optional
resizing: booleanif true, resize the node to fit; if false, move the node to fit
the engine instance for chaining
Prepare and validate a node's coordinates and values for the current grid. This ensures the node has valid position, size, and properties before being added to the grid.
the node to prepare and validate
Optional
resizing: booleanif true, resize the node down if it's out of bounds; if false, move it to fit
the prepared node with valid coordinates
Remove all nodes from the grid.
if true (default), marks all nodes for DOM removal
if true (default), triggers removal events
the engine instance for chaining
Remove the given node from the grid.
the node to remove
if true (default), marks node for DOM removal
if true, adds node to removedNodes list for event triggering
the engine instance for chaining
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
Optional
saveCB: SaveFcnSort the nodes array from first to last, or reverse. This is called during collision/placement operations to enforce a specific order.
sort direction: 1 for ascending (first to last), -1 for descending (last to first)
the engine instance for chaining
Attempt to swap the positions of two nodes if they meet swapping criteria. Nodes can swap if they are the same size or in the same column/row, not locked, and touching.
first node to swap
second node to swap
true if swap was successful, false if not possible, undefined if not applicable
return true if can fit in grid height constrain only (always true if no maxRow)
Defines the GridStack engine that handles all grid layout calculations and node positioning. This is the core engine that performs grid manipulation without any DOM operations.
The engine manages:
NOTE: Values should not be modified directly - use the main GridStack API instead to ensure proper DOM updates and event triggers.