Skip to content

Commit d1a7b02

Browse files
committed
fix: animationName and animationDuration incorrectly mapping
1 parent 4c71d1f commit d1a7b02

File tree

5 files changed

+16
-20
lines changed

5 files changed

+16
-20
lines changed

example/src/App.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
1-
import { StyleSheet, Text, View } from "react-native";
1+
import { Text, View } from "react-native";
22

33
import { StatusBar } from "expo-status-bar";
44

55
import "../global.css";
66

77
export default function App() {
88
return (
9-
<View style={styles.container}>
10-
<Text className="text-green-800 duration-[5s] transition-colors">
11-
Hello world!!!
12-
</Text>
9+
<View className="flex-1 bg-white items-center justify-center">
10+
<Text className="text-blue-800 animate-bounce">Hello world!!!</Text>
1311
<StatusBar style="auto" />
1412
</View>
1513
);
1614
}
17-
18-
const styles = StyleSheet.create({
19-
container: {
20-
flex: 1,
21-
backgroundColor: "#fff",
22-
alignItems: "center",
23-
justifyContent: "center",
24-
},
25-
});

src/__tests__/compiler/compiler.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ test.skip("animations", () => {
258258
animationDirection: ["normal"],
259259
animationDuration: [1000],
260260
animationFillMode: ["none"],
261-
animationIterationCount: [-1],
261+
animationIterationCount: ["infinite"],
262262
animationName: [[{}, "animation", ["spin"], 1]],
263263
animationPlayState: ["running"],
264264
animationTimingFunction: ["linear"],

src/compiler/keyframes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import type { StylesheetBuilder } from "./stylesheet";
1010

1111
export function parseIterationCount(
1212
value: AnimationIterationCount[],
13-
): number[] {
13+
): (number | "infinite")[] {
1414
return value.map((value) => {
15-
return value.type === "infinite" ? -1 : value.value;
15+
return value.type === "infinite" ? value.type : value.value;
1616
});
1717
}
1818

src/native/styles/resolve.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export type StyleResolver = (
3838
const functionResolvers = {
3939
...shorthands,
4040
...functions,
41-
animationName: shorthands.animation,
4241
lineHeight,
4342
em,
4443
rem,

src/native/styles/shorthands/animation.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ export const animation: StyleFunctionResolver = (
7676
return;
7777
}
7878

79-
animationShortHandTuples.pop();
80-
8179
const nameTuple = animationShortHandTuples.find(
8280
(tuple) => tuple[1] === "animationName",
8381
);
@@ -121,3 +119,13 @@ export const animation: StyleFunctionResolver = (
121119

122120
return applyShorthand(animationShortHandTuples);
123121
};
122+
123+
export const animationName: StyleFunctionResolver = (
124+
resolveValue,
125+
value,
126+
get,
127+
options,
128+
) => {
129+
const shorthand: any = animation(resolveValue, value, get, options);
130+
return shorthand.animationName;
131+
};

0 commit comments

Comments
 (0)