Skip to content

Commit 7d4c456

Browse files
cursoragentskovhus
andcommitted
Update keyframes-multiAnimationInterpolatedDuration: use interpolated duration for both animations
Co-authored-by: Kenneth Skovhus <skovhus@users.noreply.github.com>
1 parent 0841428 commit 7d4c456

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

test-cases/keyframes-multiAnimationInterpolatedDuration.input.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Multi-animation with interpolated duration in one segment
1+
// Multi-animation with interpolated duration in both segments
22
import * as React from "react";
33
import styled, { keyframes } from "styled-components";
44

@@ -20,20 +20,18 @@ const slideIn = keyframes`
2020
}
2121
`;
2222

23-
// First animation has interpolated duration, second has static duration
24-
// When $duration is provided, animationDuration should be "${$duration}ms, 1s"
25-
// not just "${$duration}ms" which would drop the second animation's duration
23+
// Both animations share the same interpolated duration prop
2624
const AnimatedCard = styled.div<{ $duration?: number }>`
27-
animation: ${fadeIn} ${(props) => props.$duration ?? 200}ms ease, ${slideIn} 1s linear;
25+
animation: ${fadeIn} ${(props) => props.$duration ?? 200}ms ease, ${slideIn} ${(props) => props.$duration ?? 1000}ms linear;
2826
padding: 20px;
2927
background: white;
3028
`;
3129

3230
export function App() {
3331
return (
3432
<div style={{ display: "flex", flexDirection: "column", gap: 16, padding: 16 }}>
35-
<AnimatedCard>Default (200ms, 1s)</AnimatedCard>
36-
<AnimatedCard $duration={500}>Custom (500ms, 1s)</AnimatedCard>
33+
<AnimatedCard>Default (200ms, 1000ms)</AnimatedCard>
34+
<AnimatedCard $duration={500}>Custom (500ms, 500ms)</AnimatedCard>
3735
</div>
3836
);
3937
}

test-cases/keyframes-multiAnimationInterpolatedDuration.output.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Multi-animation with interpolated duration in one segment
1+
// Multi-animation with interpolated duration in both segments
22
import * as React from "react";
33
import * as stylex from "@stylexjs/stylex";
44

@@ -26,17 +26,16 @@ type AnimatedCardProps = React.PropsWithChildren<{
2626
duration?: number;
2727
}>;
2828

29-
// First animation has interpolated duration, second has static duration
30-
// When $duration is provided, animationDuration should be "${$duration}ms, 1s"
31-
// not just "${$duration}ms" which would drop the second animation's duration
29+
// Both animations share the same interpolated duration prop
3230
function AnimatedCard(props: AnimatedCardProps) {
3331
const { children, duration } = props;
3432

3533
return (
3634
<div
3735
sx={[
3836
styles.animatedCard,
39-
duration != null && styles.animatedCardAnimationDuration(`${duration ?? 200}ms, 1s`),
37+
duration != null &&
38+
styles.animatedCardAnimationDuration(`${duration ?? 200}ms, ${duration ?? 1000}ms`),
4039
]}
4140
>
4241
{children}
@@ -47,16 +46,16 @@ function AnimatedCard(props: AnimatedCardProps) {
4746
export function App() {
4847
return (
4948
<div style={{ display: "flex", flexDirection: "column", gap: 16, padding: 16 }}>
50-
<AnimatedCard>Default (200ms, 1s)</AnimatedCard>
51-
<AnimatedCard duration={500}>Custom (500ms, 1s)</AnimatedCard>
49+
<AnimatedCard>Default (200ms, 1000ms)</AnimatedCard>
50+
<AnimatedCard duration={500}>Custom (500ms, 500ms)</AnimatedCard>
5251
</div>
5352
);
5453
}
5554

5655
const styles = stylex.create({
5756
animatedCard: {
5857
animationName: `${fadeIn}, ${slideIn}`,
59-
animationDuration: "200ms, 1s",
58+
animationDuration: "200ms, 1000ms",
6059
animationTimingFunction: "ease, linear",
6160
padding: 20,
6261
backgroundColor: "white",

0 commit comments

Comments
 (0)