Skip to content

feat(scrollview): Add ScrollStarting and ZoomStarting events - #23690

Merged
MartinZikmund merged 7 commits into
feature/breakingchangesfrom
dev/doti/scrollview-scroll-zoom-starting
Jul 14, 2026
Merged

MartinZikmund merged 7 commits into
feature/breakingchangesfrom
dev/doti/scrollview-scroll-zoom-starting

Conversation

@morning4coffe-dev

@morning4coffe-dev morning4coffe-dev commented Jul 8, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: closes #23688

PR Type:

✨ Feature

What changed? 🚀

Ports the WinUI ScrollStarting and ZoomStarting event flow to ScrollPresenter and forwards both events through ScrollView.

The port:

  • exposes the WinUI-compatible event args and event surface;
  • tracks anticipated offsets and zoom factors across queued ScrollTo, ScrollBy, ZoomTo, and ZoomBy requests;
  • implements non-animated InteractionTracker.TryUpdateScale on Skia, including scale clamping and center-point-preserving position updates, so ZoomStarting now fires at runtime;
  • preserves request correlation IDs and validates single and successive request forwarding with runtime tests.

PR Checklist ✅

@github-actions

github-actions Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @morning4coffe-dev's task in 6m 41s —— View job


Review: feat(scrollview): Add ScrollStarting and ZoomStarting events

  • Gather context and read PR diff
  • Review new event args classes (ScrollingScrollStartingEventArgs, ScrollingZoomStartingEventArgs)
  • Review ScrollPresenter changes
  • Review ScrollView changes
  • Review test coverage
  • Post inline comments and summary

Verdict: ship with minor nits — the feature is correctly implemented and the WinUI surface is faithfully reproduced.

Cross-cutting observations

Architecture & correctness (no blocking issues)

The anticipated-view state machine (m_anticipatedZoomedHorizontalOffset/Vertical/ZoomFactor) is the right approach for accumulating successive relative-scroll requests and is a faithful port from WinUI. The four reset sites (animated hand-off, velocity-based request, all-operations-completed, delayed-operations-interrupted) match the C++ original.

The subscribe/unsubscribe symmetry in HookScrollPresenterEvents / UnhookScrollPresenterEvents is correct and matches the pattern used for all other events.

Events use TypedEventHandler<T, TArgs> throughout — no event Action or event Action<T>. ✓

foreach / collection mutation fix
The new .ToArray() on m_interactionTrackerAsyncOperations in CompleteDelayedOperations (ScrollPresenter.cs:6422) fixes a pre-existing collection-mutation-during-iteration bug. Good catch.

[Ignore] on VerifyZoomStartingForwarding
The ignore reason is well-documented and accurate. The [Ignore] on the ScrollPresenter-level zoom tests in ScrollPresenterViewChangeTests.cs also applies for the same underlying reason (InteractionTracker scale updates not yet implemented on Skia).

Inline findings posted

Severity File Finding
Low ScrollPresenter.cs:7103 UpdateAnticipatedOffset / UpdateAnticipatedZoomFactor: NaN != NaN is always true, so the guard never prevents a NaN→NaN re-assignment. Harmless today (trace logging commented out) but will cause spurious trace output if those traces are ever enabled.
Low ScrollViewTests.cs:513 Missing [GitHubWorkItem("https://github.com/unoplatform/uno/issues/23688")] on VerifyScrollStartingForwarding — project rules require this for issue-covering tests.
Low ScrollViewTests.cs:583 Same [GitHubWorkItem] annotation missing on VerifyZoomStartingForwarding.
Nit ScrollPresenter.cs:6422 New .ToArray() lacks an explanatory comment, inconsistent with the same pattern at line 3852.

@unodevops

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @morning4coffe-dev's task in 4m 15s —— View job


Review: feat(scrollview): Add ScrollStarting and ZoomStarting events

  • Gather context and read PR diff
  • Review new event args classes (ScrollingScrollStartingEventArgs, ScrollingZoomStartingEventArgs)
  • Review ScrollPresenter changes
  • Review ScrollView changes
  • Review test coverage
  • Post inline comments and summary

Verdict: ship with one remaining nit — all findings from the first review round have been addressed; one minor comment placement issue remains.

Summary

The previous review round's findings are resolved:

  • NaN guard (sameNaN check) applied correctly to all three anticipated-view fields ✓
  • [GitHubWorkItem("…/issues/23688")] added to both VerifyScrollStartingForwarding and VerifyZoomStartingForwarding ✓

New finding (nit)

The fix-commit added // Uno: iterate a snapshot to allow Remove() inside the loop. at line 6368 (CompleteOperations), which already had a // Uno docs: ToArray call… comment — leaving two comments saying the same thing. Meanwhile, the newly added .ToArray() in CompleteDelayedOperations (~line 6423) still has no comment. The comment landed on the wrong call. One inline comment posted above.

Cross-cutting observations (no blocking issues)

  • Event forwarding correctness: OnScrollPresenterScrollStarting / OnScrollPresenterZoomStarting forward the same args object to ScrollView.ScrollStarting / ScrollView.ZoomStarting. The internal-setter properties on the args mean subscribers cannot mutate them — safe to share. ✓
  • Subscribe/unsubscribe symmetry: HookScrollPresenterEvents / UnhookScrollPresenterEvents are balanced for both new events. ✓
  • State machine: ResetAnticipatedView() at all four required sites (animated hand-off, velocity-based request, all-operations-completed, delayed-operations-interrupted). ✓
  • AreAllScrollControllersCollapsed null-guard: adds defensive null-checks for m_horizontalScrollControllerElement / m_verticalScrollControllerElement — a correct fix that prevents a NullReferenceException if either is unset. ✓
  • GetScrollPresenterPart() removal: only used in ScrollViewTestHooks; safe to remove since the hooks call site was updated in the same commit. ✓
  • No event Action / event Action<T>: all new events use TypedEventHandler<T, TArgs>. ✓

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 221384 found UI Test snapshots differences: skia-linux-screenshots: 0, skia-windows-screenshots: 2364

Details
  • skia-linux-screenshots: 0 changed over 2366

  • skia-windows-screenshots: 2364 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png-dark
    • AndroidWindowInsets.png
    • AppWindowFeatures.png-dark
    • AppBar_KeyBoard.png-dark
    • AppXamlDefinedResources.png
    • ApplicationViewSizing.png
    • Attributed_text_Supserscript.png-dark
    • AppWindowClosing.png-dark
    • AutoBorderStretchwithtopmargin.png-dark
    • Attributed_text_FontSize_Changing.png-dark
    • AutoSuggestBox_BitmapIcon.png-dark
    • AutoBorderStretchwithrightmargin.png-dark
    • AutoSuggestBox_SoftKeboard.png
    • AutoSuggestBoxChosenSuggestion.png-dark
    • Basics Pivot Test.png
    • BadgeNotificationTests.png
    • Battery.png
    • BasicThemeResources.png-dark
    • BeginTime_MultipleAnimations.png-dark
    • BasicThemeResources.png

Co-authored-by: Copilot <[email protected]>
Copilot-Session: eb8b5c8e-97cc-4099-a059-fc645d4fcb8e
@github-actions

github-actions Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @morning4coffe-dev's task in 3m 2s —— View job


Review: feat(scrollview): Add ScrollStarting and ZoomStarting events

  • Gather context and read PR diff
  • Review remaining open finding (duplicate comment in CompleteDelayedOperations)
  • Review latest commit changes
  • Post inline comments for any new findings
  • Post summary

Verdict: ship — the last open finding is resolved and no new issues found.

Round 3 summary

The latest commit (be5d929c chore: Clarify snapshot iteration) correctly addresses the final nit from round 2:

  • Removed the accidental duplicate // Uno: iterate a snapshot to allow Remove() inside the loop. comment from CompleteOperations (line 6368), which already had an equivalent // Uno docs: comment.
  • Added that same comment at the correct location in CompleteDelayedOperations (line 6422), where it was originally requested and still absent.

The fix is precise and touches nothing else.

Full-PR cross-cutting observations (no blocking issues)

The complete diff was re-read for this round. Everything is clean:

  • Anticipated-view state machine (m_anticipatedZoomedHorizontalOffset / Vertical / ZoomFactor): initialization, accumulation for relative requests, clamping to scrollable range, and four-site reset (animated hand-off, velocity-based request, all-ops-completed, delayed-ops-interrupted) are all correct. ✓
  • RaiseScrollStarting / RaiseZoomStarting argument values: always valid (non-NaN) at call sites because AnticipatedZoomedHorizontalOffset() / AnticipatedZoomedVerticalOffset() / AnticipatedZoomFactor() fall back to the live field when the anticipated field is NaN. ✓
  • NaN guard in UpdateAnticipatedOffset / UpdateAnticipatedZoomFactor: the sameNaN check correctly treats NaN-to-NaN as equal (float/double IEEE equality would otherwise treat them as unequal). ✓
  • AreAllScrollControllersCollapsed null-guard: correct; prevents NullReferenceException when either scroll controller element is unset. ✓
  • GetScrollPresenterPart removal and ScrollControllersAutoHidingChangedDbg rename: both internal, verified no other callers. ✓
  • Subscribe/unsubscribe symmetry for both new events in HookScrollPresenterEvents / UnhookScrollPresenterEvents. ✓
  • Event declarations: TypedEventHandler<T, TArgs> throughout — no event Action. ✓
  • Test coverage: [GitHubWorkItem] on both test methods, [Ignore] on VerifyZoomStartingForwarding with a clear reason, VerifyScrollStartingForwarding exercises both correlation-ID forwarding and anticipated-offset values. ✓
  • MUX Reference headers: added or corrected in all touched files, consistent with code-style rules. ✓

@morning4coffe-dev
morning4coffe-dev marked this pull request as ready for review July 11, 2026 09:38
@github-actions

github-actions Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @morning4coffe-dev's task in 3m 3s —— View job


Review: feat(scrollview): Add ScrollStarting and ZoomStarting events

  • Gather context and read PR diff
  • Review remaining open finding (duplicate comment in CompleteDelayedOperations)
  • Review latest commit changes
  • Post inline comments for any new findings
  • Post summary

Verdict: ship — all previous review findings are resolved; no new issues found.

Round 3 Summary

The outstanding nit from round 2 — the duplicate // Uno: iterate a snapshot… comment mistakenly placed in CompleteOperations (which already had the // Uno docs: comment), leaving CompleteDelayedOperations without a comment — has been correctly fixed by commit be5d929c:

  • CompleteOperations now has exactly one comment: the original // Uno docs: ToArray call is to avoid modifying the collection while iterating.
  • CompleteDelayedOperations now has: // Uno: iterate a snapshot to allow Remove() inside the loop.

Both comments are present in the right places with no duplication. ✓

Cross-cutting observations (all clear)

Area Status
Event forwarding correctness (OnScrollPresenterScrollStarting / OnScrollPresenterZoomStarting) ✓
Subscribe/unsubscribe symmetry in HookScrollPresenterEvents / UnhookScrollPresenterEvents ✓
IScrollPresenter interface updated with both new events ✓
sameNaN guard in UpdateAnticipatedOffset / UpdateAnticipatedZoomFactor ✓
ResetAnticipatedView() called at all four required sites ✓
Events use TypedEventHandler<T, TArgs> — no event Action / event Action<T> ✓
[GitHubWorkItem("…/issues/23688")] on both VerifyScrollStartingForwarding and VerifyZoomStartingForwarding ✓
[Ignore] on VerifyZoomStartingForwarding with documented reason ✓
ScrollBarController.cs header updated to standard MUX Reference … commit b8cfb8490 format ✓
AreAllScrollControllersCollapsed null-guards for m_horizontalScrollControllerElement / m_verticalScrollControllerElement ✓

No new inline comments posted — the PR is clean.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 221845 found UI Test snapshots differences: skia-linux-screenshots: 73, skia-windows-screenshots: 92

Details
  • skia-linux-screenshots: 73 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Buttons.png-dark
    • Buttons.png
    • Examples.png-dark
    • Examples.png
    • Gamepad_CurrentReading.png-dark
    • Basics Pivot Test.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • CompositionPath.png
    • DoubleImageBrushInList.png-dark
    • DataTransferManager.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • Gamepad_Enumeration.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
  • skia-windows-screenshots: 92 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • DropDownButtonPage.png-dark
    • Examples.png-dark
    • DropDownButtonPage.png
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • Focus_FocusVisual_Properties.png-dark
    • Gamepad_CurrentReading.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • Buttons.png
    • ClipboardTests.png-dark
    • CompositionPath.png
    • DisplayInformation.png-dark
    • DisplayInformation.png
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • ButtonClippingTestsControl.png-dark
    • ColorPickerSample.png
    • ContentControl_Inheritance.png

@MartinZikmund

Copy link
Copy Markdown
Member

@morning4coffe-dev description says "Note: on Skia, ZoomStarting can't currently fire because InteractionTracker scale updates are not yet implemented, so its runtime test is marked [Ignore] with that reason." - I think it is needed to add this too, otherwise the event does not have too much use

morning4coffe-dev and others added 2 commits July 13, 2026 11:07
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 99c2bedc-ec77-464f-9ccc-33fee5a3a211
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 99c2bedc-ec77-464f-9ccc-33fee5a3a211
@github-actions

github-actions Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @morning4coffe-dev's task in 8m 30s —— View job


Review: feat(scrollview): Add ScrollStarting and ZoomStarting events (Round 4)

  • Gather context and read PR diff
  • Review latest commit (fix(scrollview): Enable ZoomStarting on Skia)
  • Review InteractionTracker scale implementation
  • Review new ScrollView / ScrollPresenter tests
  • Post inline comments for findings
  • Post summary

Verdict: ship with one nit — the TryUpdateScale implementation is architecturally sound and correctly enables ZoomStarting on Skia. One code-style nit remains.

Round 4 Summary

The two latest commits (8d5fd1a5 feat(scrollview): Complete starting event port and 30641230 fix(scrollview): Enable ZoomStarting on Skia) address Martin's concern by implementing TryUpdateScale on Skia's InteractionTracker, making ZoomStarting fire correctly for programmatic zoom operations.

What changed

  • InteractionTracker: Scale is now a real mutable field (_scale); SetScale() and TryUpdateScale() are implemented with correct clamping, center-point geometry, and deferred ValuesChanged.
  • State classes: All four InteractionTrackerState subclasses implement TryUpdateScale with the correct semantics — Idle/Inertia/CustomAnimation apply the scale change; Interacting fires RequestIgnored (matching WinUI's behavior when user interaction takes precedence).
  • VerifyZoomStartingForwarding un-ignored: Previously marked [Ignore] because scale wasn't implemented; now runs correctly.
  • New tests: VerifySuccessiveScrollStartingValues and VerifySuccessiveZoomStartingValues verify the anticipated-view state machine with successive back-to-back operations. Math checks out. ✓
  • Given_InteractionTracker_Scale: Two new tests confirm MaxScale clamping (5.0f → 4.0f given MaxScale=4.0f) and center-point position adjustment.

Findings

Severity Location Finding
Nit ScrollViewTestHooks.cs line 2 // MUX Reference ScrollViewTestHooks.cpp, commit b8cfb8490 was removed in the "Complete starting event port" commit. Code-style rules require keeping that attribution line for ported MUX files. Should be restored as line 3.

Cross-cutting observations (all clear)

Area Status
TryUpdateScale state machine across all InteractionTrackerState subclasses ✓
SetScale OnPropertyChanged(Scale) fired synchronously before ValuesChanged (needed for expression-animation boundary updates) ✓ intentional
VerifyZoomStartingForwarding correctly un-ignored ✓
Given_InteractionTracker_Scale MaxScale clamping: TryUpdateScale(5.0f) → 4.0f when MaxScale=4.0f ✓
When_TryUpdateScale_WithCenterPoint center-point geometry: newPos = ratio*(pos+center)−center ✓
Generated/3.0.0.0/.../InteractionTracker.cs: TryUpdateScale stub replaced with // Skipping already declared method ✓
VerifySuccessiveZoomStartingValues anticipated-zoom-factor accumulation (1→2→3) ✓
ZoomTo/ZoomBy programmatic calls bypass ScrollingZoomMode.Disabled (user-interaction-only flag) ✓
No event Action / event Action<T> added ✓

@github-actions

Copy link
Copy Markdown
Contributor

WinAppSDK sync generator drift detected on 3064123

The Uno.WinAppSDKSyncGenerator produced changes that are not committed on this PR.

To apply automatically (PRs from branches in this repo only): comment /apply-sync-gen on this PR and a bot will push chore: Sync generator run to the head branch.

To apply manually (required for PRs from forks):

  1. Download the sync-generator-patch artifact from this run.
  2. In your local checkout of the PR branch:
    git apply sync-generator.patch
    git add -A
    git commit -m "chore: Sync generator run"
    git push
    

Or re-run the generator locally on Windows via build\run-api-sync-tool.cmd.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 99c2bedc-ec77-464f-9ccc-33fee5a3a211
@github-actions

github-actions Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @morning4coffe-dev's task in 4m 56s —— View job


Review: feat(scrollview): Add ScrollStarting and ZoomStarting events (Round 5)

  • Gather context and read latest changes
  • Review sync-generator commit (9a6abec0)
  • Verify outstanding findings from round 4
  • Review TryUpdateScale / SetScale correctness
  • Review new tests (Given_InteractionTracker_Scale, VerifySuccessiveZoom/ScrollStartingValues)
  • Post inline comments for any new findings
  • Post summary

Verdict: ship — all round 4 findings are resolved; no new issues found.

Round 5 Summary

The sync-generator commit (9a6abec0) correctly closes out the last open nit from round 4: ScrollViewTestHooks.cs (and .h.cs) now carry the // MUX Reference … commit b8cfb8490 attribution header. The generated InteractionTracker.cs stub for TryUpdateScale is correctly replaced with // Skipping already declared method.

Full-PR cross-cutting observations (all clear)

Area Status
TryUpdateScale state machine: Idle stays Idle; Inertia/CustomAnimation → Idle; Interacting fires RequestIgnored ✓
SetScale synchronous OnPropertyChanged(Scale) before position clamp — lets expression-animation boundaries update before Vector3.Clamp ✓
ValuesChanged always enqueued after both sync property-change notifications fire ✓
IdleStateEntered enqueued after ValuesChanged for Inertia→Idle transitions (correct WinUI ordering) ✓
MaxScale clamping in all state TryUpdateScale overrides before SetScale ✓
VerifySuccessiveScrollStartingValues: both ScrollBy calls in the same RunOnUIThread.Execute block; anticipated-offset accumulates synchronously → second ScrollStarting sees (15, 27) before any ValuesChanged dispatch ✓
VerifySuccessiveZoomStartingValues: ZoomBy(+1.0) twice from zoom=1 → anticipated zoom 2→3; math is correct ✓
When_TryUpdateScale_WithCenterPoint: initial pos=(0,0,0), scale 1→2, center=(10,20,0) → new pos = 2×(0+10,0+20,0)−(10,20,0) = (10,20,0) = center ✓
[GitHubWorkItem] on all four new test methods ✓
VerifyZoomStartingForwarding correctly un-ignored (TryUpdateScale now implemented) ✓
AnticipatedZoomFactor() division used in ZoomBy anticipated-offset math is safe (zoom factor always ≥ MinScale > 0) ✓
Subscribe/unsubscribe symmetry for both events in HookScrollPresenterEvents / UnhookScrollPresenterEvents ✓
All events use TypedEventHandler<T, TArgs> — no event Action / event Action<T> ✓
MUX Reference headers present on all ported files ✓

No inline comments posted — the PR is clean.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 221997 found UI Test snapshots differences: skia-linux-screenshots: 68, skia-windows-screenshots: 79

Details
  • skia-linux-screenshots: 68 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ColorPickerSample.png
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • CompositionPath.png
    • DisplayInformation.png-dark
    • EllipsemaskingEllipseGrid.png
    • CornerRadiusControls.png
    • Focus_FocusVisual_Properties.png-dark
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • Image_Margin_Large.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • ElementLevelTheme.png-dark
    • Examples.png-dark
    • Examples.png
  • skia-windows-screenshots: 79 changed over 2368

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Focus_FocusVisual_Properties.png-dark
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
    • Basics Pivot Test.png
    • Buttons.png-dark
    • Buttons.png
    • Gamepad_Enumeration.png-dark
    • Examples.png
    • ElementLevelTheme.png-dark
    • ExpanderColorValidationPage.png-dark
    • ElementLevelTheme.png
    • Image_UseTargetSize.png
    • CalendarView_Theming.png-dark
    • ClipboardTests.png-dark
    • DropDownButtonPage.png-dark
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • Gamepad_CurrentReading.png-dark

@MartinZikmund
MartinZikmund enabled auto-merge July 14, 2026 12:04
@MartinZikmund
MartinZikmund merged commit 74b76b4 into feature/breakingchanges Jul 14, 2026
47 checks passed
@MartinZikmund
MartinZikmund deleted the dev/doti/scrollview-scroll-zoom-starting branch July 14, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants