@snapgridjs/core
v0.7.0
Published
Framework-agnostic layout-engine adapter for snapgrid (thin layer over react-grid-layout/core).
Maintainers
Readme
@snapgridjs/core
Framework-agnostic layout engine for snapgrid — a thin adapter over react-grid-layout/core that owns the math: collision, compaction, move/resize, and responsive breakpoint resolution.
Most users want
@snapgridjs/react, not this package.@snapgridjs/coreis the framework-agnostic layout math (compaction, geometry, move/resize, the drag-session state machine) the higher layers build on. Reach for it directly only to drive layout calculations without dnd-kit or React. Building a binding for another framework? Start from@snapgridjs/dnd— the dnd-kit engine that builds on this.
Install
pnpm add @snapgridjs/coreWhat's here
Pure functions and types — no React, no DOM:
- Layout ops —
moveElement,moveItemWithCompactor,resizeItemWithCompactor,insertItemWithCompactor,removeItemWithCompactor. - Compactors —
verticalCompactor,horizontalCompactor,noCompactor, andgetCompactor. - Positioning —
calcXY,calcWH,calcGridItemPosition,toPositionParams. - Drag sessions —
beginDrag,dragTo,nudge,beginResize,dragResize,commitLayout. - Responsive —
getBreakpointFromWidth,findOrGenerateResponsiveLayout. - Core types:
Layout,LayoutItem,Compactor,DragSession,GridConfig, and more.
→ See the API reference.
License
MIT © Edmond Leung
