Custom Modules
States
How StringData and its nested state containers should be read from custom modules.
States
For custom modules, this.data is the live runtime state surface. It is an instance of StringData, which aggregates several state containers.
Top-Level State Containers
StringData currently exposes:
scrollviewportcursorrendertimesystem
scroll
Use this.data.scroll when the module depends on:
- current scroll position
- target scroll position
- lerped scroll values
- displacement and direction
- container and scroll mode state
This is usually the primary state surface for scroll-driven modules.
viewport
Use this.data.viewport when the module depends on:
- window width and height
- content size
- transform scale
- base rem
This matters for geometry, unit parsing, and layout-sensitive output.
cursor
Use this.data.cursor when the module needs:
- raw target pointer position
- smoothed pointer position
- per-frame cursor step values
- cursor velocity
This is especially important for custom interaction modules.
time
Use this.data.time when the module depends on:
- frame delta
- current frame time
- elapsed runtime time
This is useful for time-based animation and damping behavior.
render
this.data.render is a holder for external rendering context references. Many modules will never need it, but it exists for integrations that coordinate with a render engine.
system
this.data.system holds runtime-level flags such as debug overlay visibility and other system-oriented switches.
Authoring Rule
Treat this.data as read-mostly shared state.
Good pattern:
- read from
this.data - derive your own output
- write to DOM or events through your module
Bad pattern:
- mutate unrelated runtime state just because it is reachable
If a custom module needs to directly rewrite core state outside its own responsibility, the design usually needs another pass.