LearnNewsExamplesServices
Frontmatter
id8914
titleConsolidate Grid Touch Scrolling into Main Thread Addon
stateClosed
labels
enhancementairefactoringarchitectureperformance
assigneestobiu
createdAtJan 30, 2026, 2:03 PM
updatedAtJan 30, 2026, 2:14 PM
githubUrlhttps://github.com/neomjs/neo/issues/8914
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 30, 2026, 2:14 PM

Consolidate Grid Touch Scrolling into Main Thread Addon

Closed v11.24.0 enhancementairefactoringarchitectureperformance
tobiu
tobiu commented on Jan 30, 2026, 2:03 PM

Problem: Currently, Neo.grid.ScrollManager handles touch scrolling logic (lastTouch positions, owner tracking) inside the App Worker, causing unnecessary cross-worker messaging and latency. Meanwhile, mouse scrolling has been successfully moved to the Neo.main.addon.GridDragScroll for superior performance.

Solution: Consolidate all drag-to-scroll logic (both mouse and touch) into the GridDragScroll Main Thread Addon. This will make the addon the "single source of truth" for grid scrolling interactions.

Architecture Changes:

  1. Refactor Neo.main.addon.GridDragScroll:

    • Implement touchstart, touchmove, touchend handlers.
    • In register(), detect Neo.config.hasTouchEvents.
    • If touch enabled: Attach touch listeners (passive: false, capture: true) instead of mouse listeners.
    • Unified logic: Route both input types to the same delta tracking and scrolling implementation.
    • Control: Use preventDefault() on touch moves to replace native scrolling with precise 1:1 drag-scrolling.
  2. Cleanup Neo.grid.ScrollManager:

    • Remove all mobile-specific logic (lastTouchX, lastTouchY, touchMoveOwner).
    • Remove touchcancel and touchend listeners from construct.
    • Remove the hasTouchEvents guard from updateDragScrollAddon to enable the addon for all environments.

Benefits:

  • Performance: Zero-latency touch scrolling by avoiding App Worker round-trips.
  • Maintainability: Centralized scrolling logic in one place.
  • Consistency: Identical behavior across desktop and mobile.
tobiu added the enhancement label on Jan 30, 2026, 2:03 PM
tobiu added the ai label on Jan 30, 2026, 2:03 PM
tobiu added the refactoring label on Jan 30, 2026, 2:03 PM
tobiu added the architecture label on Jan 30, 2026, 2:03 PM
tobiu added the performance label on Jan 30, 2026, 2:03 PM
tobiu referenced in commit 374c1eb - "enhancement: Consolidate Grid Touch Scrolling into Main Thread Addon (#8914)" on Jan 30, 2026, 2:13 PM
tobiu assigned to @tobiu on Jan 30, 2026, 2:14 PM
tobiu
tobiu Jan 30, 2026, 2:14 PM

Input from Gemini 3 Pro:

✦ I have successfully consolidated the grid touch scrolling logic into the Neo.main.addon.GridDragScroll addon.

Changes Implemented

1. Main Thread Addon (src/main/addon/GridDragScroll.mjs)

  • Touch Support: Implemented touchstart, touchmove, and touchend handlers.
  • Unified Logic: The addon now acts as the single source of truth for all drag scrolling.
    • In register(): It checks Neo.config.hasTouchEvents.
    • Mobile: Attaches touch listeners (passive: false, capture: true). Uses preventDefault() on touchmove to replace native scrolling with precise, zero-latency drag scrolling.
    • Desktop: Attaches mouse listeners as before.
  • Documentation: Updated class JSDoc to reflect the dual support.

2. ScrollManager Refactor (src/grid/ScrollManager.mjs)

  • Cleanup: Removed all legacy App Worker-side touch tracking (lastTouchX, lastTouchY, touchMoveOwner) and listeners.
  • Simplification: onBodyScroll and onContainerScroll are now purely for syncing state, with no drag logic.
  • Renaming: Renamed mouseDragScroll_ to dragScroll_ to reflect the broader scope.
  • Registration: The updateDragScrollAddon method now unconditionally delegates to the addon, allowing the addon to decide which listeners to attach based on the environment.

Outcome

This architecture change eliminates the overhead of passing high-frequency touch events between the Main Thread and App Worker. Grid scrolling on mobile devices is now handled directly in the Main Thread, resulting in zero-latency performance comparable to native scrolling, while maintaining the exact same logic and behavior as the desktop mouse drag.

tobiu closed this issue on Jan 30, 2026, 2:14 PM