Skip to content

Commit af2ff71

Browse files
committed
fix(lab): NavigationStack on one touch model and the animator's Reduced Motion
On meta#8076 @ 1203525 (AST-094 as meta#8316 states it): the back swipes are touch behaviour under any finger, Android and iOS alike, keyed on a coarse primary pointer (useTouchPresentation); a mouse goes back with the bar's button. Reduced Motion is the animator's default (design:reduced-motion): under a finger the screens fade in place in 200 ms with no dimming, under a mouse they change at once, and what a finger's release starts fades on any pointer (touchRelease). navigation.backChevronReducedMotionDelayMs retires with its option; the motion roles and the docs golden are regenerated.
1 parent 51d4908 commit af2ff71

5 files changed

Lines changed: 44 additions & 59 deletions

File tree

‎.changeset/uikit-navigation-stack-constants.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
'@astryxdesign/core': patch
33
---
44

5-
[experimental] The `uikit` table in `@astryxdesign/core/motion/experimental` gains the navigation values the lab NavigationStack runs on, each measured on iOS 26.2: `navigation.contentPopHysteresis` (the content back swipe's 27 pt start), `navigation.interactivePopVelocitySamples` (the release velocity averages the last 3), `springs.navigationBackButton` (the back chevron's fade), and `navigation.backChevronPushDelayMs` / `navigation.backChevronReducedMotionDelayMs` (when the chevron starts fading in on a push, with and without Reduce Motion). The catalog gains `@astryx.navigationStack.back`.
5+
[experimental] The `uikit` table in `@astryxdesign/core/motion/experimental` gains the navigation values the lab NavigationStack runs on, each measured on iOS 26.2: `navigation.contentPopHysteresis` (the content back swipe's 27 pt start), `navigation.interactivePopVelocitySamples` (the release velocity averages the last 3), `springs.navigationBackButton` (the back chevron's fade), and `navigation.backChevronPushDelayMs` (when the chevron starts fading in on a push). The catalog gains `@astryx.navigationStack.back`.
66

77
@vjeux

‎packages/cli/assets/docs/motion.doc.mjs‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,6 @@ const calmTheme = defineTheme({
190190
'duration',
191191
'60ms',
192192
],
193-
[
194-
'navigation.backChevronReducedMotionDelayMs',
195-
'--motion-navigation-back-chevron-reduced-motion-delay-ms',
196-
'duration',
197-
'175ms',
198-
],
199193
[
200194
'navigation.transitionMs',
201195
'--motion-navigation-transition-ms',

‎packages/cli/test/__golden__/no-icon-set/docs-topics.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
"touch-motion",
202202
"best-practices"
203203
],
204-
"skeleton": "5a0cc086e0126b2ee9d89bdd4051299f012b477fae9fb16e94281d884c146bb9",
204+
"skeleton": "5432dd5358492991307ea7e63bb670b82c981fab751ba48577d8d79af5b1f483",
205205
"mentions": []
206206
},
207207
"principles": {

‎packages/core/src/motion/uikit/navigation.ts‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,6 @@ export const navigation = {
113113
* 0.825, 0.642, 0.474 … at 34 ms steps), Oct 24 2026
114114
*/
115115
backChevronPushDelayMs: 60,
116-
/**
117-
* The same delay under Reduce Motion with Prefer Cross-Fade Transitions,
118-
* after the screens start cross-fading.
119-
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
120-
* iPhone 17 Pro, the same push with Reduce Motion + Prefer Cross-Fade on
121-
* (F4 batch 62b): the cross-fade's start fitted with its 0.5 s
122-
* (0.42, 0, 0.58, 1) curve (rms 0.0035); the chevron (0.036, 0.104,
123-
* 0.19, 0.28, 0.37 …) fits the 0.4 s spring from 176.8 ms after it within
124-
* 0.010, Oct 24 2026
125-
*/
126-
backChevronReducedMotionDelayMs: 175,
127116
} as const;
128117

129118
// Each spring, duration and curve above is a motion role a theme may retune

‎packages/lab/src/NavigationStack/NavigationStack.tsx‎

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@
4848
* home-screen web app (`navigator.standalone`), and the content swipe
4949
* ignores touches that start in that edge band.
5050
*
51-
* Reduce Motion follows UIKit's cross-fade (the animator's substitution):
52-
* the incoming screen fades in where it lands while the outgoing one fades
53-
* out, with no travel and no dimming; the bars swap at once. The back swipe
54-
* still tracks the finger.
51+
* Reduced Motion is the animator's (`design:reduced-motion`): under a finger
52+
* the incoming screen fades in where it lands and the outgoing one fades out
53+
* in 200 ms, with no travel and no dimming; under a mouse the change is
54+
* immediate. A finger's back swipe still tracks it; what its release
55+
* starts fades on any pointer.
5556
*
5657
* Accessibility: covered screens are `inert`. A push moves focus to the new
5758
* screen's title; a pop returns it to the control that pushed the screen.
@@ -77,7 +78,6 @@ import {
7778
} from 'react';
7879
import * as stylex from '@stylexjs/stylex';
7980
import {
80-
prefersReducedMotion,
8181
resolveMotion,
8282
solveSpring,
8383
toSpring,
@@ -90,7 +90,7 @@ import {
9090
PanGestureRecognizer,
9191
ScreenEdgePanGestureRecognizer,
9292
useGestureRecognizer,
93-
useTouchIdiom,
93+
useTouchPresentation,
9494
} from '@astryxdesign/core/gestures/experimental';
9595
import {useTranslator} from '@astryxdesign/core/i18n';
9696
import {focusOutlineStyles} from '@astryxdesign/core/utils';
@@ -754,7 +754,7 @@ export function NavigationStack<T>({
754754
under: string | null,
755755
spring: SpringDescription,
756756
dp: number | undefined,
757-
reducedMotion: 'crossfade' | 'keep',
757+
release: boolean,
758758
underBar: 'rest' | 'ride',
759759
): Promise<boolean> => {
760760
const width = cardsRef.current?.clientWidth ?? 0;
@@ -766,29 +766,31 @@ export function NavigationStack<T>({
766766
const topLayers = layersOf(top);
767767
const underLayers = layersOf(under);
768768
const handles = [];
769-
// Reduce Motion: UIKit cross-fades. The animator substitutes the fade
770-
// for the travel; `crossfadeAs` says which card enters (fades in where
771-
// it lands) and which leaves (fades out in place).
769+
// Reduced Motion is the animator's; `crossfadeAs` says which card
770+
// enters (fades in where it lands) and which leaves (fades out in
771+
// place). A finger's release fades on any pointer (`touchRelease`).
772772
if (topLayers?.card) {
773773
handles.push(
774774
topLayers.card.animate(
775775
{x: values.topX},
776776
{spring, velocity: velocity ? {x: velocity.topX} : undefined},
777-
{at, reducedMotion, crossfadeAs: to === 0 ? 'entrance' : 'exit'},
777+
{
778+
at,
779+
touchRelease: release,
780+
crossfadeAs: to === 0 ? 'entrance' : 'exit',
781+
},
778782
),
779783
);
780784
startedRef.current = at;
781785
}
782786
// The bars move with their cards (each screen's bar is part of it in
783-
// UIKit): the incoming one covers the outgoing title. Under Reduce
784-
// Motion they swap at once, as UIKit's titles do.
785-
const barMotion = reducedMotion === 'crossfade' ? 'instant' : 'keep';
787+
// UIKit): the incoming one covers the outgoing title.
786788
if (topLayers?.bar) {
787789
handles.push(
788790
topLayers.bar.animate(
789791
{x: values.topX},
790792
{spring, velocity: velocity ? {x: velocity.topX} : undefined},
791-
{at, reducedMotion: barMotion},
793+
{at, touchRelease: release},
792794
),
793795
);
794796
}
@@ -797,7 +799,7 @@ export function NavigationStack<T>({
797799
underLayers.bar.animate(
798800
{x: values.underX},
799801
{spring, velocity: velocity ? {x: velocity.underX} : undefined},
800-
{at, reducedMotion: barMotion},
802+
{at, touchRelease: release},
801803
),
802804
);
803805
}
@@ -806,17 +808,21 @@ export function NavigationStack<T>({
806808
underLayers.card.animate(
807809
{x: values.underX},
808810
{spring, velocity: velocity ? {x: velocity.underX} : undefined},
809-
{at, reducedMotion, crossfadeAs: to === 1 ? 'entrance' : 'exit'},
811+
{
812+
at,
813+
touchRelease: release,
814+
crossfadeAs: to === 1 ? 'entrance' : 'exit',
815+
},
810816
),
811817
);
812818
}
813819
for (const dim of [underLayers?.dim, underLayers?.barDim]) {
814820
if (dim == null) {
815821
continue;
816822
}
817-
if (reducedMotion === 'crossfade' && prefersReducedMotion()) {
818-
// UIKit's Reduce Motion cross-fade has no dimming: the shade
819-
// belongs to the slide.
823+
if (dim.reducedMotion({touchRelease: release}) !== 'off') {
824+
// A Reduced Motion fade has no dimming: the shade belongs to the
825+
// slide.
820826
dim.set({opacity: 0});
821827
} else {
822828
handles.push(
@@ -826,7 +832,7 @@ export function NavigationStack<T>({
826832
spring,
827833
velocity: velocity ? {opacity: velocity.dim} : undefined,
828834
},
829-
{at},
835+
{at, touchRelease: release},
830836
),
831837
);
832838
}
@@ -847,7 +853,7 @@ export function NavigationStack<T>({
847853
* push's delay is a motion role, resolved under the stack's theme.
848854
*/
849855
const fadeBack = useCallback(
850-
(kind: 'push' | 'pop', under: string | null) => {
856+
(kind: 'push' | 'pop', under: string | null, release = false) => {
851857
const isRoot = under != null && view.models[0]?.key === under;
852858
if (!isRoot) {
853859
return;
@@ -857,13 +863,7 @@ export function NavigationStack<T>({
857863
const delay =
858864
kind === 'pop'
859865
? 0
860-
: resolveMotion(
861-
element,
862-
navigation,
863-
prefersReducedMotion()
864-
? 'backChevronReducedMotionDelayMs'
865-
: 'backChevronPushDelayMs',
866-
);
866+
: resolveMotion(element, navigation, 'backChevronPushDelayMs');
867867
if (kind === 'push') {
868868
backControl.animator.set({opacity: 1});
869869
backChevron.animator.set({opacity: 0});
@@ -887,7 +887,7 @@ export function NavigationStack<T>({
887887
velocity: t => (t < delayS ? 0 : fade.velocity(t - delayS)),
888888
},
889889
},
890-
{at: startedRef.current, reducedMotion: 'keep'},
890+
{at: startedRef.current, touchRelease: release},
891891
);
892892
},
893893
[view.models, backControl.animator, backChevron.animator],
@@ -994,7 +994,7 @@ export function NavigationStack<T>({
994994
under,
995995
springs.navigationPush,
996996
wasRunning ? undefined : programmaticVelocity('push'),
997-
'crossfade',
997+
false,
998998
'ride',
999999
);
10001000
fadeBack('push', under);
@@ -1005,10 +1005,10 @@ export function NavigationStack<T>({
10051005
under,
10061006
springs.navigationInteractivePopFinish,
10071007
release.velocity,
1008-
'keep',
1008+
true,
10091009
'rest',
10101010
);
1011-
fadeBack('pop', under);
1011+
fadeBack('pop', under, true);
10121012
} else {
10131013
if (!wasRunning) {
10141014
setProgress(0, top, under, 'ride');
@@ -1019,7 +1019,7 @@ export function NavigationStack<T>({
10191019
under,
10201020
springs.navigationPop,
10211021
wasRunning ? undefined : programmaticVelocity('pop'),
1022-
'crossfade',
1022+
false,
10231023
'ride',
10241024
);
10251025
fadeBack('pop', under);
@@ -1238,7 +1238,7 @@ export function NavigationStack<T>({
12381238
swipe.under,
12391239
springs.navigationInteractivePopFinish,
12401240
velocity,
1241-
'keep',
1241+
true,
12421242
'rest',
12431243
).then(finished => {
12441244
if (runningRef.current?.id === id) {
@@ -1282,9 +1282,10 @@ export function NavigationStack<T>({
12821282
[view.models, layersOf, setProgress, animateProgress, settle],
12831283
);
12841284

1285-
// The back swipes are UIKit idioms: elsewhere (Android's system back owns
1286-
// both edges) back is the bar's button and the browser's history.
1287-
const isIos = useTouchIdiom() === 'ios';
1285+
// The back swipes are touch behaviour: one model under any finger (a
1286+
// coarse primary pointer), Android and iOS alike; a mouse goes back with
1287+
// the bar's button and the browser's history.
1288+
const isTouch = useTouchPresentation().isTouch;
12881289
// In a browser tab the screen's leading edge is the browser's own back
12891290
// swipe (iOS Safari keeps it, AST-094 FR22): the edge swipe only runs in a
12901291
// home-screen web app, and the content swipe ignores touches that start
@@ -1306,7 +1307,8 @@ export function NavigationStack<T>({
13061307
}),
13071308
recognizer => onSwipe(recognizer, 0),
13081309
{
1309-
isEnabled: isIos && canPop && isInteractivePopEnabled && !browserOwnsEdge,
1310+
isEnabled:
1311+
isTouch && canPop && isInteractivePopEnabled && !browserOwnsEdge,
13101312
},
13111313
);
13121314
// iOS 26's back swipe from anywhere in the content. It waits for the edge
@@ -1332,7 +1334,7 @@ export function NavigationStack<T>({
13321334
),
13331335
}).requireToFail(edge),
13341336
recognizer => onSwipe(recognizer, CONTENT_DEAD_ZONE_PX),
1335-
{isEnabled: isIos && canPop && isInteractivePopEnabled},
1337+
{isEnabled: isTouch && canPop && isInteractivePopEnabled},
13361338
);
13371339
// The content swipe pops toward the trailing edge: rightward unless RTL.
13381340
useLayoutEffect(() => {

0 commit comments

Comments
 (0)