StringTune/Docs

Modules

Lifecycle And Device Behavior

How StringCursor binds hover listeners, reacts to DOM rebuilds, handles navigation cleanup, and disables itself on coarse pointers.

Type
Built-in module
Status
Stable
Scope
Global
Activation
stringTune.use(StringCursor)

Lifecycle And Device Behavior

StringCursor is not just a hover helper. It also owns a fair amount of runtime lifecycle behavior.

Coarse Pointer Devices

The module checks isCoarsePointer() in the constructor. If the environment is treated as coarse-pointer oriented, the module disables itself.

That is why a cursor setup may appear fully inactive on touch-first or narrow environments even if the target markup exists.

Object Connection

When a cursor target connects, the runtime:

  • attaches center tracking for the object
  • stores mouseenter and mouseleave handlers on the object
  • subscribes to local object enter and leave events
  • caches initial width and height

That caching matters because local cursor math should not trigger layout reads every frame.

Resize Behavior

On resize, the module refreshes cached dimensions for connected targets.

It is also conservative on mobile rebuild permissions:

  • mobile.rebuild.height = false
  • mobile.rebuild.width = false
  • mobile.rebuild.scrollHeight = false

DOM Rebuilds And Mutations

StringCursor refreshes portal registration when DOM rebuild or DOM mutation introduces or removes portal elements.

That is how dynamically inserted cursor portals can still become active without a full page reload.

The module explicitly guards against hover state getting stuck during navigation or DOM removal.

It binds cleanup logic to:

  • beforeunload
  • pagehide
  • visibilitychange

It also checks removed nodes in DOM mutation handling, so if a hovered target disappears from the DOM, the module can clean up hover state and portal classes.

Older Parsed Flags

The runtime still parses some older keys like target-disable, target-style-disable, and target-class, but the current docs intentionally treat them as non-contractual unless the behavior is clearly part of the supported module surface.

So for public docs, focus on:

  • string-cursor-target
  • string-cursor-class
  • string-alignment
  • string-cursor-enter
  • string-cursor-leave
  • string-cursor-leave-hold
  • string-cursor-vars
  • string-cursor-lerp