LearnNewsExamplesServices
Frontmatter
id9050
titlePerf: Optimize DomAccess.syncAligns to avoid scroll thrashing
stateClosed
labels
aiperformancecore
assigneestobiu
createdAtFeb 8, 2026, 5:27 PM
updatedAtFeb 8, 2026, 5:29 PM
githubUrlhttps://github.com/neomjs/neo/issues/9050
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtFeb 8, 2026, 5:29 PM

Perf: Optimize DomAccess.syncAligns to avoid scroll thrashing

Closed v12.0.0 aiperformancecore
tobiu
tobiu commented on Feb 8, 2026, 5:27 PM

Neo.main.DomAccess.syncAligns triggers a full realignment cycle on every scroll event. This can cause significant layout thrashing (performance "hammering"), especially when scrolling inside a floating container (like a Picker's list) that is itself aligned to another element.

Goal: Optimize syncAligns to filter scroll events. It should only trigger re-alignment if the scrolling element is an ancestor of the alignment target or the constraint element. If the scroll event originates from within the aligned component itself (or an unrelated container), the alignment logic should be skipped.

Implementation Plan:

  1. Modify syncAligns in src/main/DomAccess.mjs.
  2. Check if the event type is scroll.
  3. If it is, verify if the event.target contains the align.targetElement or align.constrainToElement.
  4. If neither is contained, return early and skip align().

This will prevent unnecessary calculations and DOM read/writes during scrolling interactions within floating components.

tobiu added the ai label on Feb 8, 2026, 5:27 PM
tobiu added the performance label on Feb 8, 2026, 5:27 PM
tobiu added the core label on Feb 8, 2026, 5:27 PM
tobiu referenced in commit d79dbae - "perf: Optimize DomAccess.syncAligns to avoid scroll thrashing (#9050)" on Feb 8, 2026, 5:28 PM
tobiu
tobiu Feb 8, 2026, 5:29 PM

Input from Gemini 3 Pro:

✦ I have implemented the optimization in src/main/DomAccess.mjs.

The syncAligns method now checks if the event type is scroll. If it is, and the target is not the document/window, it verifies if the scroll target contains either the align.targetElement or the align.constrainToElement.

If the scroll target is unrelated (e.g., scrolling inside the picker's own content), the re-alignment logic is skipped. This effectively stops the layout thrashing loop.

Merged in commit d79dbae23.

tobiu assigned to @tobiu on Feb 8, 2026, 5:29 PM
tobiu closed this issue on Feb 8, 2026, 5:29 PM