Skip to content

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 ​

Component.constructor

Properties ​

PropertyModifierTypeDefault valueDescriptionInherited from
bounceDurationpublicnumberundefined--
brakepublicnumberundefined0..1 deceleration after release. 0 ≈ glides a long way, 1 ≈ stops almost immediately.-
contentpublicnumber | nullundefinedThe scrollable content entity (a child of this viewport). Null → the system no-ops.-
dirtypublicbooleantrue-Component.dirty
elasticpublicbooleanundefinedPulled past an edge while dragged (with resistance), springing back over bounceDuration.-
enabledpublicbooleantrue-Component.enabled
horizontalpublicbooleanundefined--
horizontalScrollbarpublicnumber | nullundefinedEntities with a ScrollbarComponent that show this view's scroll position.-
inertiapublicbooleanundefined--
offsetXpublicnumberundefinedAPI-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.-
offsetYpublicnumberundefined--
velocityXpublicnumber0System-owned runtime state (not dirty-tracked, not in the schema).-
velocityYpublicnumber0--
verticalpublicbooleanundefined--
verticalScrollbarpublicnumber | nullundefined--
wheelSpeedpublicnumberundefinedMouse 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 ​

ParameterType
targetnumber | Entity | null

Returns ​

void


SetPercentX() ​

ts
SetPercentX(percent): void;

0 = leading edge, 1 = trailing edge. Uses the last-known max extent.

Parameters ​

ParameterType
percentnumber

Returns ​

void


SetPercentY() ​

ts
SetPercentY(percent): void;

Parameters ​

ParameterType
percentnumber

Returns ​

void

© 2026 PlayAdGentic