sdxc

Type to search, or start from one of these:

[ @sdxc/ui/behaviors ]

ResizeSession

Headless pointer-resize engine backing the resizeHandle(axis) mixin.

import { ResizeSession } from "@sdxc/ui/behaviors";

Usage

Owns one resizable panel group's active pointer session. move() re-solves every panel's size from the constraints captured at start(), cascading into further panels so a drag only takes what the group can give up.

Signature

new ResizeSession()

Properties

PropertyTypeDescription
isActivebooleanWhether a pointer session is in progress between start() and end().
activeHandleIndexnumber | nullIndex of the handle being dragged in the active session, or null when no session is active.
panelsreadonly ResizeSession.Panel[]Every panel's current resolved size and constraints, in group order. Returns a defensive copy on every read, so mutating the result never affects the session's own state.

Methods

MethodDescription
start(options: ResizeSession.StartOptions): voidBegins a pointer session on one handle of a panel group, capturing the panels' sizes and constraints as the baseline every subsequent move() in this session solves from.
move(pointerPosition: number): voidRe-solves every panel's size for the current pointer position and dispatches change. A no-op when no session is active, so a mixin can forward every pointermove without guarding on isActive itself.
end(): voidConcludes the active session, keeping the panels at their last solved sizes, and dispatches end. A no-op when no session is active.
cancel(): voidAborts the active session, reverting every panel to the size it had when start() was called, then dispatches change (for the reverted sizes) followed by end. A no-op when no session is active.

The events, constants and types its module publishes, each imported from @sdxc/ui/behaviors too.

Interface

ResizeSession.PanelInput

A panel as supplied to start(): its current size and, optionally, the size constraints the solver must respect. size, min, and max are all expressed as percentages of the panel group's main-axis size (0-100).

MemberTypeDescription
idstringStable identifier the consumer uses to map a resolved size back to its panel element.
sizenumberCurrent size, as a percentage of the group's main-axis size.
min?numberSmallest percentage this panel may shrink to. Defaults to 0 when omitted.
max?numberLargest percentage this panel may grow to. Defaults to 100 when omitted.
Interface

ResizeSession.Panel

A panel's resolved state as read from an in-progress or finished session: min and max are always concrete, defaulted values.

MemberTypeDescription
idstringStable identifier, carried over unchanged from the matching PanelInput.
sizenumberCurrent size, as a percentage of the group's main-axis size.
minnumberSmallest percentage this panel may shrink to.
maxnumberLargest percentage this panel may grow to.
Interface

ResizeSession.StartOptions

Snapshot passed to start(): the panel group's layout and constraints at the moment a pointer session begins on one of its handles.

MemberTypeDescription
handleIndexnumberIndex of the handle being dragged; it sits between panels[handleIndex] and panels[handleIndex + 1].
panelsreadonly PanelInput[]Every panel in the group, in visual order along the resize axis.
pointerPositionnumberPointer coordinate along the resize axis (clientX for a horizontal group, clientY for a vertical one) at pointer-down.
groupSizenumberSize, in pixels, of the panel group measured along the resize axis — used to convert pixel pointer deltas into percentage units.
Interface

ResizeSession.Events

Events a ResizeSession dispatches; read the panels getter for the state behind each one.

MemberTypeDescription
changeEventDispatched whenever constraint solving produces new panel sizes, from a pointer move or a cancelled session reverting.
endEventDispatched once a session concludes, whether by end() or cancel().

Written by Sergio Xalambrí. Follow @sergiodxa for new packages, or sponsor the work.