-
-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vertical-stack and right snapDirection shows reversed order. #663
Comments
To ensure that the cards in a vertical stack with Here's the updated renderItem={({ index, animationValue }) => (
<Item
key={index}
index={index}
animationValue={animationValue}
entering={FadeInRight.delay(
snapDirection === "right" ? index * 100 : (viewCount - index) * 100,
).duration(200)}
/>
)} This change ensures that the delay for the |
@dosu |
To create the import React from "react";
import { View, Text, TouchableWithoutFeedback } from "react-native";
import Animated, { useAnimatedStyle, interpolate, Extrapolate } from "react-native-reanimated";
import faker from "faker";
import { SBImageItem } from "./SBImageItem"; // Assuming SBImageItem is a custom component
import { SBTextItem } from "./SBTextItem"; // Assuming SBTextItem is a custom component
import styles from "./styles"; // Assuming styles is a stylesheet
import { LongPressGestureHandler } from "react-native-gesture-handler";
import Constants from "expo-constants";
const Item: React.FC<{
index: number;
animationValue: Animated.SharedValue<number>;
}> = ({ index, animationValue }) => {
const animStyle = useAnimatedStyle(() => {
const inputRange = [index - 1, index, index + 1];
const outputRange = [-50, 0, 50]; // Example values for translation
return {
transform: [
{
translateX: interpolate(
animationValue.value,
inputRange,
outputRange,
Extrapolate.CLAMP
),
},
],
};
}, [animationValue, index]);
const enablePretty = Constants?.expoConfig?.extra?.enablePretty || false;
const [isPretty, setIsPretty] = React.useState(enablePretty);
return (
<LongPressGestureHandler
onActivated={() => {
setIsPretty(!isPretty);
}}
>
<Animated.View
style={[
{
backgroundColor: "white",
flex: 1,
justifyContent: "center",
overflow: "hidden",
alignItems: "center",
},
animStyle,
]}
>
{isPretty ? (
<SBImageItem
showIndex={false}
key={index}
style={styles.image}
index={index}
/>
) : (
<SBTextItem
style={styles.text}
index={index}
/>
)}
<Text
style={{
color: "white",
fontWeight: "600",
fontSize: 40,
width: 100,
textAlign: "center",
}}
>
{faker.name.fullName().slice(0, 2).toUpperCase()}
</Text>
</Animated.View>
</LongPressGestureHandler>
);
};
export default Item; This code defines the |
it doesn't work .. |
Describe the bug
When I set the snapDirection to right, the card shows reversed order when swiping to right.
As shown on the demo, When it's set to left, each cards match the data's order,
0,1,2,3,4,5...
But if I set it to right, the cards show
5,4,3,2,1...
which is reversed order.To Reproduce
Steps to reproduce the behavior:
It could be checked in the demo website.
Expected behavior
I want regardless of the direction, the cards show according to the data's order, not reversed.
Screenshots
Versions (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: