Class: ScrollViewComponent
A drag-scrollable region. Add it to the viewport entity — the fixed, masked window — and point it at a larger content child via SetContent. ScrollViewSystem drives the drag, inertia, and edge-clamping, moving the content's TransformComponent each tick.
Rig the host is expected to have (not created here — see docs/COMPONENTS.md): viewport : UITransformComponent (window size) + GraphicsComponent (rect matching size) + MaskComponent (maskSource=null → clip descendants). BlockInputComponent is auto-added by the system so the whole window captures drags. content : child of the viewport, UITransformComponent sized to the full scrollable size.
Scroll amount is exposed as offsetX/offsetY (pixels from the leading edge). It's the single source of truth: drag and inertia write it, and game code can write it (or SetPercent*) to scroll programmatically — both paths flow through the same clamp + apply.
Extends
Constructors
Constructor
ts
new ScrollViewComponent(): ScrollViewComponent;Returns
ScrollViewComponent
Inherited from
Properties
| Property | Modifier | Type | Default value | Description | Inherited from |
|---|---|---|---|---|---|
bounceDuration | public | number | undefined | - | - |
brake | public | number | undefined | 0..1 deceleration after release. 0 ≈ glides a long way, 1 ≈ stops almost immediately. | - |
content | public | number | null | undefined | The scrollable content entity (a child of this viewport). Null → the system no-ops. | - |
dirty | public | boolean | true | - | Component.dirty |
elastic | public | boolean | undefined | Pulled past an edge while dragged (with resistance), springing back over bounceDuration. | - |
enabled | public | boolean | true | - | Component.enabled |
horizontal | public | boolean | undefined | - | - |
horizontalScrollbar | public | number | null | undefined | Entities with a ScrollbarComponent that show this view's scroll position. | - |
inertia | public | boolean | undefined | - | - |
offsetX | public | number | undefined | API-controllable scroll position, in pixels from the leading (left / top) edge. Clamped to [0, maxOffset] by the system (past it only mid-bounce). Writing either scrolls on the next tick. | - |
offsetY | public | number | undefined | - | - |
velocityX | public | number | 0 | System-owned runtime state (not dirty-tracked, not in the schema). | - |
velocityY | public | number | 0 | - | - |
vertical | public | boolean | undefined | - | - |
verticalScrollbar | public | number | null | undefined | - | - |
wheelSpeed | public | number | undefined | Mouse wheel / trackpad multiplier while the game runs; 0 turns the wheel off. | - |
Methods
GetMaxOffsetX()
ts
GetMaxOffsetX(): number;Returns
number
GetMaxOffsetY()
ts
GetMaxOffsetY(): number;Returns
number
GetPercentX()
ts
GetPercentX(): number;Returns
number
GetPercentY()
ts
GetPercentY(): number;Returns
number
SetContent()
ts
SetContent(target): void;Accepts an Entity wrapper or a raw id (or null). Stored as an id so a destroyed Entity wrapper can't keep a stale reference alive — mirrors WidgetComponent.SetAnchorTarget.
Parameters
| Parameter | Type |
|---|---|
target | number | Entity | null |
Returns
void
SetPercentX()
ts
SetPercentX(percent): void;0 = leading edge, 1 = trailing edge. Uses the last-known max extent.
Parameters
| Parameter | Type |
|---|---|
percent | number |
Returns
void
SetPercentY()
ts
SetPercentY(percent): void;Parameters
| Parameter | Type |
|---|---|
percent | number |
Returns
void