Frontmatter
| id | 8913 |
| title | Main Thread Addon for High-Performance Grid Drag Scrolling |
| state | Closed |
| labels | enhancementaiperformance |
| assignees | tobiu |
| createdAt | Jan 30, 2026, 12:51 PM |
| updatedAt | Jan 30, 2026, 1:52 PM |
| githubUrl | https://github.com/neomjs/neo/issues/8913 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Jan 30, 2026, 1:52 PM |
Main Thread Addon for High-Performance Grid Drag Scrolling
tobiu assigned to @tobiu on Jan 30, 2026, 1:51 PM

tobiu
Jan 30, 2026, 1:52 PM
Input from Gemini 3 Pro:
✦ I have successfully implemented the
Neo.main.addon.GridDragScrolladdon to move grid drag-scrolling logic to the Main Thread.Implementation Details
1. Main Thread Addon (
src/main/addon/GridDragScroll.mjs)
- Purpose: Handles the drag-to-scroll interaction directly in the UI thread to eliminate worker messaging latency.
- Event Handling:
- Listens for
mousedownon the grid body with{capture: true}to intercept drag starts even if children stop propagation.- Attaches
mousemoveandmouseuplisteners todocument(with{capture: true}) during an active drag. This supports "over-drag," allowing the user to drag outside the grid/window bounds without losing the scroll operation.- Respects the
neo-draggableexclusion check to avoid conflicting with other drag operations.- Direct DOM Manipulation: Updates
scrollLeftandscrollTopdirectly on the registered container and body elements for maximum performance.2. ScrollManager Refactor (
src/grid/ScrollManager.mjs)
- Lifecycle Awareness: Introduced a
mounted_reactive config.- Dynamic Registration:
- Registers with the addon only when
mouseDragScrollis true AND the grid ismounted.- Unregisters when
mouseDragScrollis disabled or the grid is unmounted.- Targets the
${bodyId}__wrapperelement to ensure vertical scrolling applies to the correct scroll container.- Cleanup: Removed the legacy App Worker-side mouse event listeners (
mousedown,mousemove,mouseup) and their handlers.3. Grid Container Integration (
src/grid/Container.mjs)
- Updated
afterSetMountedto propagate themountedstate to thescrollManager. This ensures theScrollManagerknows when the DOM is ready for addon registration.Outcome
This architecture change resolves the performance bottleneck caused by cross-thread
mousemoveevents. Scrolling via mouse drag on desktop is now as smooth and responsive as native touch scrolling.
tobiu closed this issue on Jan 30, 2026, 1:52 PM
To further optimize grid scrolling performance on desktop, particularly for mouse users, we propose moving the mouse-based drag-to-scroll logic entirely to the Main Thread via a specialized addon.
Problem: The current App Worker implementation relies on
mousemoveevents crossing the worker boundary. This adds messaging overhead and latency, making the drag-scroll feel "chunky" compared to the smooth, native-feeling touch scroll.Proposed Solution: Create
Neo.main.addon.GridDragScroll, a new Main Thread Addon that handles the drag-to-scroll interaction directly in the UI thread.Key Features:
mousedown,mousemove(global), andmouseup(global) in the main thread and updatescrollLeft/scrollTopdirectly on the grid elements.mousemovemessages to the App Worker during scroll operations.mouseDragScrollis enabled and the environment is not touch-enabled.documentorwindowto support "over-drag" (scrolling continues even if the mouse leaves the grid bounds), matching the robust behavior of touch scrolling.Implementation Plan:
src/main/addon/GridDragScroll.mjs.register({id, bodyId, containerId, ...})to attach listeners.src/grid/ScrollManager.mjsto dynamically import and register this addon inafterSetMouseDragScroll(if not touch).ScrollManager.mjsonce the addon is proven.Constraints:
Neo.config.hasTouchEventsto avoid conflict with native touch scrolling.mouseDragScrollconfig toggle dynamically.