Build with XuiView Markdown

Animation lifetime and motion preferences

Finish a transition cleanly when its page disappears, and avoid unnecessary motion when the user asks for less. A view's animation should not outlive the reason it is visible.

The finite transition example includes the complete policy: subscribe to device preferences while active, jump to the target when reduced motion is requested, and stop scheduling frames on deactivation.

Make stopping an explicit state change

OnDeactivate sets running to false, settles position at target, and clears the starting time. A frame already scheduled may still arrive, but AnimateCore returns without requesting another one.

Settling at the destination is one useful policy. A drawing tool might instead preserve the current position. Choose deliberately, particularly if the view instance will be reused. Do not leave a half-finished operation with no rule for what appears when the page returns.

If the animation uses a timer, subscription, or background task outside the frame system, stop or cancel that work too. The framework cannot automatically cancel work you started independently of the view.

Read and observe the preference

Resolve IDeviceInfo from the view's service chain and check PrefersReducedMotion. The example reads it when a transition begins and subscribes to Changed while active. If the preference becomes true mid-transition, it applies the destination immediately and invalidates once.

Remove the handler on deactivation. A device service can live much longer than the page; retaining its event subscription retains the view as well. A named handler makes it straightforward to remove exactly the callback that was added.

Do not remove meaningful state feedback when you remove animation. The dot still reaches its new position. A loading indicator should still communicate loading through text or a static state if continuous motion is disabled.

Know what the runtime actually reports

The current iOS and Android device implementations expose reduced-motion state, while the inspected macOS and Windows implementations return a fixed false value. A missing service also does not tell the example that the user prefers reduced motion. Do not claim that checking the shared interface alone honors every operating system setting on every runtime.

For a product that requires consistent motion control now, add an application preference and combine it with the platform value. Keep that preference in a shared service so all animated components follow the same policy. The framework device preference and the app preference are separate inputs.

Verify idle behavior

Start the transition, navigate away, and wait longer than its duration. Returning should show the chosen settled state, without a burst of old updates. Repeat the navigation cycle to catch duplicate preference handlers.

Also test a preference change while moving and a zero-duration transition. Neither case should keep requesting frames after reaching the final picture. Smooth motion matters, but an idle application should be allowed to stay idle.