Skip to content
Grid LayoutExamples

Grid locks and interaction events

comins-grid-layout@0.3.0React

Toggle global editable and per-widget locked state while observing move, resize, and commit events.

  1. Drag A by its title. The log shows beforeMove:a, commit for changed geometry, and finally afterMove:a.
  2. B starts with locked: true; dragging it does not change its layout.
  3. Lock all also blocks A from moving or resizing. Unlock all restores A’s interaction.
  4. Unlock B enables interaction for B.
  5. Drag A’s bottom-right resize handle to observe beforeResize:a and afterResize:a. Geometry changes also appear in JSON.
  6. Clear events clears only the log; Reset restores initial geometry and lock settings.
Setting Scope
editable={false} Blocks pointer movement and resizing in this Grid.
widget.locked Applies constraints to that individual widget.
commands.updateWidget Updates the consumer-owned React widget definition.

Locks constrain user interaction; they are not authorization rules blocking application state commands. Both global editable and widget constraints must permit interaction.

onBeforeMove, onAfterMove, onBeforeResize, and onAfterResize receive { id, layout } notifications. They return void; returning false from a before callback is not a cancellation API. Set constraints before the interaction to block it.

onLayoutCommit passes the snapshot to commands.applyLayoutSnapshot to update React state. Identical commits are suppressed; do not assume exactly one commit for each pointer input. Initial engine synchronization can appear in the log, so clear it before a comparison. The log retains the most recent 16 entries.

This example displays start/end and commit notifications. Frame-level onMove/onResize, pixel sizes from onWidgetResizeFrame, and command transitions from onLayoutMutation serve different purposes.

Widget interaction guide · Events guide · State commands · Grid ref