Modules
Lifecycle And Device Behavior
How StringCursor binds hover listeners, reacts to DOM rebuilds, handles navigation cleanup, and disables itself on coarse pointers.
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
mouseenterandmouseleavehandlers on the object - subscribes to local object
enterandleaveevents - 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 = falsemobile.rebuild.width = falsemobile.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.
Navigation Cleanup
The module explicitly guards against hover state getting stuck during navigation or DOM removal.
It binds cleanup logic to:
beforeunloadpagehidevisibilitychange
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-targetstring-cursor-classstring-alignmentstring-cursor-enterstring-cursor-leavestring-cursor-leave-holdstring-cursor-varsstring-cursor-lerp