Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
persist-credentials: false

Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
persist-credentials: false

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
pull-requests: read
steps:
- name: Validate pull request title
uses: amannn/action-semantic-pull-request@v6.1.0
uses: amannn/action-semantic-pull-request@v6.1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
fetch-depth: 0

Expand Down
7 changes: 2 additions & 5 deletions src/components/NavigationStackProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -582,13 +582,10 @@ export function NavigationStackProvider(
initialParams: isControlled ? undefined : props.initialParams,
}),
);
const timeoutRef = useRef<number | null>(null);
const state = isControlled ? props.state : internalState;
const stateRef = useRef<NavigationStackState>(state);
const timeoutRef = useRef<number | null>(null);

useEffect(() => {
stateRef.current = state;
}, [state]);
stateRef.current = state;

useEffect(() => {
return () => {
Expand Down
14 changes: 14 additions & 0 deletions src/components/NavigationStackScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ export interface NavigationStackSceneProps {
animationEasing?: string;
/** Stagger-based delay in milliseconds (`spec.stagger × sceneIndex`). */
animationDelay?: number;
/**
* Inline `transform` fallback matching the animation's `from` keyframe.
* Applied only on entering scenes so the element starts at the correct off-screen
* position during the brief window before `@keyframes` registers in the cascade.
* The running animation always overrides this via the animation value layer.
*/
animationFromTransform?: string;
/**
* Inline `opacity` fallback matching the animation's `from` keyframe.
* Same purpose as `animationFromTransform`.
*/
animationFromOpacity?: number;
/** When true, applies `overflow: hidden` to clip scene content during the transition. */
clipContent?: boolean;
children?: ReactNode;
Expand Down Expand Up @@ -69,6 +81,8 @@ export function NavigationStackScene(
pointerEvents: props.isActive ? 'auto' : 'none',
visibility: props.isActive || props.transitionState ? 'visible' : 'hidden',
overflow: props.clipContent ? 'hidden' : undefined,
transform: props.animationFromTransform,
opacity: props.animationFromOpacity,
animation: props.animationName
? `${props.animationName} ${duration}ms ${easing} ${delay}ms both`
: undefined,
Expand Down
23 changes: 20 additions & 3 deletions src/components/NavigationStackViewport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ export function NavigationStackViewport(
delay: number;
easing: string;
clip: boolean;
fromTransform: string | undefined;
fromOpacity: number | undefined;
}
>(),
};
Expand All @@ -348,7 +350,14 @@ export function NavigationStackViewport(
const cssBlocks: string[] = [];
const animations = new Map<
string,
{ name: string | undefined; delay: number; easing: string; clip: boolean }
{
name: string | undefined;
delay: number;
easing: string;
clip: boolean;
fromTransform: string | undefined;
fromOpacity: number | undefined;
}
>();

renderableEntries.forEach((entry) => {
Expand Down Expand Up @@ -386,13 +395,19 @@ export function NavigationStackViewport(
delay: keyframeResult.delay,
easing,
clip: !!spec.clip,
fromTransform:
phase === 'enter' ? keyframeResult.fromTransform : undefined,
fromOpacity:
phase === 'enter' ? keyframeResult.fromOpacity : undefined,
});
} else {
animations.set(entry.key, {
name: undefined,
delay: 0,
easing,
clip: !!spec.clip,
fromTransform: undefined,
fromOpacity: undefined,
});
}
});
Expand Down Expand Up @@ -435,7 +450,7 @@ export function NavigationStackViewport(
...props.style,
}}
>
<style>{dynamicCss || undefined}</style>
<style>{dynamicCss || ''}</style>
{props.renderEmpty?.() ?? null}
</div>
);
Expand All @@ -455,7 +470,7 @@ export function NavigationStackViewport(
...props.style,
}}
>
{dynamicCss ? <style>{dynamicCss}</style> : null}
<style>{dynamicCss || ''}</style>

{renderableEntries.map((entry) => {
const route = routes[entry.routeName];
Expand Down Expand Up @@ -509,6 +524,8 @@ export function NavigationStackViewport(
animationName={anim?.name}
animationEasing={anim?.easing}
animationDelay={anim?.delay}
animationFromTransform={anim?.fromTransform}
animationFromOpacity={anim?.fromOpacity}
clipContent={anim?.clip}
>
{isActive || state.isTransitioning ? (
Expand Down
19 changes: 18 additions & 1 deletion src/transitions/buildAnimationKeyframes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ export interface AnimationKeyframeResult {
css: string;
/** Animation delay in milliseconds (derived from spec.stagger × sceneIndex). */
delay: number;
/**
* CSS `transform` value of the animation's `from` keyframe (e.g. `"translateX(100%)"`).
* Apply as an inline style fallback on the entering scene so it starts at the correct
* off-screen position during the brief window before @keyframes registers in the cascade.
*/
fromTransform: string | undefined;
/**
* CSS `opacity` value of the animation's `from` keyframe.
* Apply as an inline style fallback on the entering scene for the same reason.
*/
fromOpacity: number | undefined;
}

function negateValue(value: number | string): number | string {
Expand Down Expand Up @@ -272,5 +283,11 @@ export function buildAnimationKeyframes(
`}`,
].join('\n');

return { name, css, delay };
return {
name,
css,
delay,
fromTransform: hasTranslate || hasScale ? fromTransform : undefined,
fromOpacity: hasOpacity ? opacityFrom : undefined,
};
}